# File lib/Dnsruby/zone_reader.rb, line 149 def strip_comments_meticulously(line) # We have escape characters in the text. Go through it character by # character and work out what's escaped and quoted and what's not escaped = false quoted = false pos = 0 line.each_char {|c| if (c == "\\") if (!escaped) escaped = true else escaped = false end else if (escaped) if (c >= "0" && c <= "9") # rfc 1035 5.1 \DDD pos = pos + 2 end escaped = false next else if (c == "\"") if (quoted) quoted = false else quoted = true end else if (c == ";") if (!quoted) return line[0, pos+1] end end end end end pos +=1 } return line end