From fb70c6af9c1783baa0192470b0273aeda0f2f99c Mon Sep 17 00:00:00 2001 From: stevenknight Date: Mon, 30 May 2005 18:52:46 +0000 Subject: [PATCH] Fix the Java parser's handling of backslashes. (Leanid Nazdrynau) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1301 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 4 ++++ src/engine/SCons/Tool/JavaCommon.py | 2 +- src/engine/SCons/Tool/JavaCommonTests.py | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 51fdbc3d..9a202a31 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -326,6 +326,10 @@ RELEASE 0.97 - XXX - Supply the help text when -h is used with the -u, -U or -D options. + From Leanid Nazdrynau: + + - Fix the Java parser's handling of backslashes in strings. + From Christian Neeb: - Fix the Java parser's handling of string definitions to avoid ignoring diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index 5c462881..96d6486f 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -48,7 +48,7 @@ if java_parsing: # begin and end tokens /* and */; single or double quotes; # single or double quotes preceeded by a backslash; array # declarations "[]". - _reToken = re.compile(r'(\n|//|\\[\'"]|[\'"\{\}]|[A-Za-z_][\w\.]*|' + + _reToken = re.compile(r'(\n|\\\\|//|\\[\'"]|[\'"\{\}]|[A-Za-z_][\w\.]*|' + r'/\*|\*/|\[\])') class OuterState: diff --git a/src/engine/SCons/Tool/JavaCommonTests.py b/src/engine/SCons/Tool/JavaCommonTests.py index 05d0fad3..352b7eed 100644 --- a/src/engine/SCons/Tool/JavaCommonTests.py +++ b/src/engine/SCons/Tool/JavaCommonTests.py @@ -187,6 +187,21 @@ public class Test { assert pkg_dir == None, pkg_dir assert classes == ['Test'], classes + def test_backslash(self): + """Test backslash handling""" + + pkg_dir, classes = SCons.Tool.JavaCommon.parse_java("""\ +public class MyTabs +{ + private class MyInternal + { + } + private final static String PATH = "images\\\\"; +} +""") + assert pkg_dir == None, pkg_dir + assert classes == ['MyTabs$MyInternal', 'MyTabs'], classes + if __name__ == "__main__": suite = unittest.TestSuite() tclasses = [ parse_javaTestCase ] -- 2.26.2