From 28d938dfebf79ace56ea8b0b7ec27a3bbd756a16 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Wed, 1 Oct 2008 11:02:08 +0000 Subject: [PATCH] Fix the regular expression for LaTeX scanning so that it matches \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 | 7 ++++++- 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 96398415..8b1f4af0 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 44758341..648737c5 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): -- 2.26.2