From c00dc7ddff5853432abef5c15282f32c73b2c143 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Tue, 12 Oct 2004 14:01:19 +0000 Subject: [PATCH] Fix Java parsing when a string is encountered. (Christian Neeb) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1127 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 5 +++++ src/engine/SCons/Tool/JavaCommon.py | 5 ++++- src/engine/SCons/Tool/JavaCommonTests.py | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index f02407c0..93fe5a7c 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -104,6 +104,11 @@ RELEASE 0.97 - XXX - Enhance the tests to guarantee persistence of ListOption values in saved options files. + From Christian Neeb: + + - Fix the Java parser's handling of string definitions to avoid ignoring + subsequent code. + From Han-Wen Nienhuys: - Optimize variable expansion by: using the re.sub() method (when diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index 6b69c736..72196e31 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -140,9 +140,12 @@ if java_parsing: self.outer_state = outer_state self.tokens_to_find = 2 def parseToken(self, token): - # This is an anonymous class if and only if the next token is a bracket + # This is an anonymous class if and only if the next token + # is a bracket if token == '{': self.outer_state.addAnonClass() + elif token in ['"', "'"]: + return IgnoreState(token, self) return self.outer_state class SkipState: diff --git a/src/engine/SCons/Tool/JavaCommonTests.py b/src/engine/SCons/Tool/JavaCommonTests.py index 2bb3be6a..46d1955c 100644 --- a/src/engine/SCons/Tool/JavaCommonTests.py +++ b/src/engine/SCons/Tool/JavaCommonTests.py @@ -43,6 +43,9 @@ public class Foo public static void main(String[] args) { + /* This tests a former bug where strings would eat later code. */ + String hello1 = new String("Hello, world!"); + } } -- 2.26.2