Fix the regular expression for LaTeX scanning so that it matches
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 1 Oct 2008 11:02:08 +0000 (11:02 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 1 Oct 2008 11:02:08 +0000 (11:02 +0000)
\include (and other inclusion strings) after blank lines.

git-svn-id: http://scons.tigris.org/svn/scons/trunk@3525 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Scanner/LaTeX.py
src/engine/SCons/Scanner/LaTeXTests.py

index 96398415a12611430ab3e3e5b01ecb00cac78a6b..8b1f4af00a2a30cbe8a534047fcabba999f1639b 100644 (file)
@@ -103,7 +103,12 @@ class LaTeX(SCons.Scanner.Base):
 
     def __init__(self, name, suffixes, graphics_extensions, *args, **kw):
 
-        regex = '^[^%]*\\\\(include|includegraphics(?:\[[^\]]+\])?|input|bibliography|usepackage){([^}]*)}'
+        # We have to include \n with the % we exclude from the first part
+        # part of the regex because the expression is compiled with re.M.
+        # Without the \n,  the ^ could match the beginning of a *previous*
+        # line followed by one or more newline characters (i.e. blank
+        # lines), interfering with a match on the next line.
+        regex = r'^[^%\n]*\\(include|includegraphics(?:\[[^\]]+\])?|input|bibliography|usepackage){([^}]*)}'
         self.cre = re.compile(regex, re.M)
         self.graphics_extensions = graphics_extensions
 
index 44758341e5706c79d966082361d16cb729ec3b62..648737c5c17ba90946ec34223ac2b8a5fc9cddd8 100644 (file)
@@ -39,6 +39,9 @@ test = TestCmd.TestCmd(workdir = '')
 test.write('test1.latex',"""
 \include{inc1}
 \input{inc2}
+include{incNO}
+%\include{incNO}
+xyzzy \include{inc6}
 """)
 
 test.write('test2.latex',"""
@@ -58,6 +61,8 @@ test.write('inc2.tex',"\n")
 test.write(['subdir', 'inc3.tex'], "\n")
 test.write(['subdir', 'inc4.eps'], "\n")
 test.write('inc5.xyz', "\n")
+test.write('inc6.tex', "\n")
+test.write('incNO.tex', "\n")
 
 # define some helpers:
 #   copied from CTest.py
@@ -115,7 +120,7 @@ class LaTeXScannerTestCase1(unittest.TestCase):
         s = SCons.Scanner.LaTeX.LaTeXScanner()
         path = s.path(env)
         deps = s(env.File('test1.latex'), env, path)
-        headers = ['inc1.tex', 'inc2.tex']
+        headers = ['inc1.tex', 'inc2.tex', 'inc6.tex']
         deps_match(self, deps, headers)
 
 class LaTeXScannerTestCase2(unittest.TestCase):