Commit 5e8d62ed authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2188] Don't strip comments in the middle of string

parent 627a1bbe
......@@ -46,11 +46,16 @@ def pop(line):
# whitespace removed, and all other whitespace compressed to
# single spaces
#########################################################################
decomment = re.compile('\s*(?:;.*)+')
decomment = re.compile('^\s*((?:[^;"]|"[^"]*")*)\s*(?:|;.*)$')
# Regular expression explained:
# First, ignore any whitespace at the start. Then take the content,
# each bit is either a harmless character (no ; nor ") or a string -
# sequence between " " not containing double quotes. Then there may
# be a comment at the end.
def cleanup(s):
global decomment
s = s.strip().expandtabs()
s = decomment.sub('', s)
s = decomment.search(s).group(1)
return ' '.join(s.split())
#########################################################################
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment