diff options
author | Steven Knight <knight@baldmt.com> | 2010-06-15 17:01:27 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2010-06-15 17:01:27 (GMT) |
commit | 894e7eb8ee6f062f076bec3b33d13d19c475faaa (patch) | |
tree | 64467db0c059aa39aaf6f44dfa207394865947b1 /src/engine/SCons/Scanner | |
parent | a571ee0bb24bcaf976cd8b313688a7287c4edbeb (diff) | |
download | SCons-894e7eb8ee6f062f076bec3b33d13d19c475faaa.zip SCons-894e7eb8ee6f062f076bec3b33d13d19c475faaa.tar.gz SCons-894e7eb8ee6f062f076bec3b33d13d19c475faaa.tar.bz2 |
Merged revisions 4727-4729,4731-4938,4940-5028 via svnmerge from
http://scons.tigris.org/svn/scons/branches/pending
........
r4942 | stevenknight | 2010-06-03 12:41:20 -0700 (Thu, 03 Jun 2010) | 13 lines
Isseu 2641: Latest drop of the TestCmd infrastructure, v. 1.3, including:
* Support for test timeouts.
* Ability to set separate match_stdout and match_stderr functions.
* Ability to set separate diff_stdout and diff_stderr functions.
* Static methods for the various underlying match* and diff* functionality.
* Ability to get at the various match* and diff* functions by attribute name.
* Got rid of checks for difflib now that Python 2.3 is the floor
(for this infrastructure, anyway).
Ripple effects in two test scripts. Added upstream unit test modules
(QMTest/Test{Cmd,Common}Tests.py). Added a README.txt file.
........
r4943 | stevenknight | 2010-06-03 13:00:31 -0700 (Thu, 03 Jun 2010) | 2 lines
Grab the correct TestCmd files with the updated version number.
........
r4946 | managan | 2010-06-04 09:39:20 -0700 (Fri, 04 Jun 2010) | 4 lines
On Windows add a '/D' to the command line so it recognizes drive letters in the
source or target file paths
........
r4947 | managan | 2010-06-04 09:51:48 -0700 (Fri, 04 Jun 2010) | 5 lines
The scanner was not parsing the dependencies in \includegraphics commands when there was whitespace (including carriage returns) in the command.
While we need a better long term fix this covers this concern.
........
r4948 | managan | 2010-06-04 11:13:12 -0700 (Fri, 04 Jun 2010) | 3 lines
Dropped an import line that is needed by the last commit of mine for Windows
depenedant option on latex command lines
........
r4949 | managan | 2010-06-04 12:27:48 -0700 (Fri, 04 Jun 2010) | 7 lines
Some latex packages break up commands where you normally could not by
using a comment character at the end of the first line.
Our current scanner broke on this and lost some dependecies.
While we need general fix, this patch solves this problem
........
r4950 | managan | 2010-06-04 15:51:36 -0700 (Fri, 04 Jun 2010) | 5 lines
Tweak how we handle comments within Latex source files when
scanning and looking for dependencies. We were adding a
space when a comment broke a line and we should not have.
........
r4984 | managan | 2010-06-07 09:37:40 -0700 (Mon, 07 Jun 2010) | 6 lines
The multi-line_include-options test failed to check for the
existence of latex. Added that so this test is skipped on
systems without latex.
........
Diffstat (limited to 'src/engine/SCons/Scanner')
-rw-r--r-- | src/engine/SCons/Scanner/LaTeX.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index d3c5c9a..b8d48b1 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -168,8 +168,11 @@ class LaTeX(SCons.Scanner.Base): # 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(?:\[[^\]]+\])?|lstinputlisting(?:\[[^\]]+\])?|input|bibliography|usepackage){([^}]*)}' + # add option for whitespace before the '[options]' or the '{filename}' + regex = r'^[^%\n]*\\(include|includegraphics(?:\s*\[[^\]]+\])?|lstinputlisting(?:\[[^\]]+\])?|input|bibliography|usepackage)\s*{([^}]*)}' 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): @@ -274,6 +277,23 @@ class LaTeX(SCons.Scanner.Base): return i, include return i, include + def canonical_text(self, text): + """Standardize an input TeX-file contents. + + Currently: + * removes comments, unwrapping comment-wrapped lines. + """ + 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 @@ -281,11 +301,13 @@ class LaTeX(SCons.Scanner.Base): # Cache the includes list in node so we only scan it once: # path_dict = dict(list(path)) - noopt_cre = re.compile('\[.*$') + # add option for whitespace (\s) before the '[' + noopt_cre = re.compile('\s*\[.*$') 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 |