##// END OF EJS Templates
ignore: fix up comment parsing...
Matt Mackall -
r5640:04c76f29 default
parent child Browse files
Show More
@@ -6,18 +6,21 b''
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 8 from i18n import _
9 import util
9 import util, re
10
11 _commentre = None
10 12
11 13 def _parselines(fp):
12 14 for line in fp:
13 if not line.endswith('\n'):
14 line += '\n'
15 escape = False
16 for i in xrange(len(line)):
17 if escape: escape = False
18 elif line[i] == '\\': escape = True
19 elif line[i] == '#': break
20 line = line[:i].rstrip()
15 if "#" in line:
16 global _commentre
17 if not _commentre:
18 _commentre = re.compile(r'((^|[^\\])(\\\\)*)#.*')
19 # remove comments prefixed by an even number of escapes
20 line = _commentre.sub(r'\1', line)
21 # fixup properly escaped comments that survived the above
22 line = line.replace("\\#", "#")
23 line = line.rstrip()
21 24 if line:
22 25 yield line
23 26
General Comments 0
You need to be logged in to leave comments. Login now