diff options
author | Steven Knight <knight@baldmt.com> | 2008-10-01 11:02:08 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2008-10-01 11:02:08 (GMT) |
commit | b92323172205e06938343f2019472b772b2eb5e5 (patch) | |
tree | 4bea5ae317bff8180733b3d77f200bc263d9b0bc | |
parent | ded68b2d8674e37df7b7f0c5a9b5bf49780bcd02 (diff) | |
download | SCons-b92323172205e06938343f2019472b772b2eb5e5.zip SCons-b92323172205e06938343f2019472b772b2eb5e5.tar.gz SCons-b92323172205e06938343f2019472b772b2eb5e5.tar.bz2 |
Fix the regular expression for LaTeX scanning so that it matches
\include (and other inclusion strings) after blank lines.
-rw-r--r-- | src/engine/SCons/Scanner/LaTeX.py | 7 | ||||
-rw-r--r-- | src/engine/SCons/Scanner/LaTeXTests.py | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 9639841..8b1f4af 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -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 diff --git a/src/engine/SCons/Scanner/LaTeXTests.py b/src/engine/SCons/Scanner/LaTeXTests.py index 4475834..648737c 100644 --- a/src/engine/SCons/Scanner/LaTeXTests.py +++ b/src/engine/SCons/Scanner/LaTeXTests.py @@ -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): |