From: W. Trevor King Date: Fri, 23 Apr 2010 00:29:06 +0000 (-0400) Subject: Added fix for text/TEX/multi-line_include_options.py. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=207f616b8f75ce3b5db5639d221d704dc294cf5c;p=scons.git Added fix for text/TEX/multi-line_include_options.py. By removing comments from the source file, we produce a "canonical" form of the input TeX that LaTeX.cre, the input regexp, can handle. --- diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 622f2a3c..f43b19cf 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -175,6 +175,8 @@ class LaTeX(SCons.Scanner.Base): # lines), interfering with a match on the next line. regex = r'^[^%\n]*\\(include|includegraphics(?:\[[^\]]+\])?|lstinputlisting(?:\[[^\]]+\])?|input|bibliography|usepackage){([^}]*)}' self.cre = re.compile(regex, re.M) + self.comment_re = re.compile(r'^([^%\n]*)(.*)$', re.M) + self.graphics_extensions = graphics_extensions def _scan(node, env, path=(), self=self): @@ -278,6 +280,18 @@ class LaTeX(SCons.Scanner.Base): return i, include return i, include + def canonical_text(self, text): + out = [] + line_continues_a_comment = False + for line in text.splitlines(): + line,comment = self.comment_re.findall(line)[0] + if line_continues_a_comment == True: + out[-1] = out[-1] + ' ' + line.lstrip() + else: + out.append(line) + line_continues_a_comment = len(comment) > 0 + return '\n'.join(out).rstrip()+'\n' + def scan(self, node): # Modify the default scan function to allow for the regular # expression to return a comma separated list of file names @@ -289,7 +303,8 @@ class LaTeX(SCons.Scanner.Base): if node.includes != None: includes = node.includes else: - includes = self.cre.findall(node.get_text_contents()) + text = self.canonical_text(node.get_text_contents()) + includes = self.cre.findall(text) # 1. Split comma-separated lines, e.g. # ('bibliography', 'phys,comp') # should become two entries