lib/vbsmin.rb
# Remove inline comments
# In VBS there is no single quote strings so it's safe to remove until the end
# of string when ecountering a single quote.
# The only case to handle if is a single quote appears in a double quote string.
Remove inline comments
In VBS there is no single quote strings so it's safe to remove until the end
of string when ecountering a single quote.
The only case to handle if is a single quote appears in a double quote string.
Remove inline comments In VBS there is no single quote strings so it ' s safe to remove until the end of string when ecountering a single quote . The only case to handle if is a single quote appears in a double quote string .
def inline_comment(line)
    double_quote = 0
    i = 0
    line.each_char do |c|
      double_quote += 1 if c == '"'
      if c == "'" && double_quote.even?
        line = line[...i]
        break
      end
      i += 1
    end
    return line
  end
def inline_comment ( line ) double_quote = 0 i = 0 line . each_char do | c | double_quote += 1 if c == '"' if c == "'" && double_quote . even? line = line [ ... i ] break end i += 1 end return line end
Remove inline comments
In VBS there is no single quote strings so it's safe to remove until the end
of string when ecountering a single quote.
Remove inline comments In VBS there is no single quote strings so it ' s safe to remove until the end of string when ecountering a single quote .
# For each single quote, if there is an odd number of double quote before # we are in a string, but if there is an even number of double quote before # we are out of a string so this is an inline comment and we can remove all # that comes after.
line
<not_specific>