From 23a0475c4676797de987c7a1e11e9593f57631a8 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 20 May 2009 09:42:26 +0200 Subject: Fix parsing method calls with null arguments in Java code In Java, "null" is represented as a keyword, not as the integer 0. The old code assumed the latter. Code such as translate("fooBar", "fooBar", null); would thus not be detected by lupdate when parsing Java files. Reviewed-by: ossi --- tools/linguist/shared/java.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/linguist/shared/java.cpp b/tools/linguist/shared/java.cpp index 912a8d7..4c244d2 100644 --- a/tools/linguist/shared/java.cpp +++ b/tools/linguist/shared/java.cpp @@ -58,7 +58,7 @@ enum { Tok_Eof, Tok_class, Tok_return, Tok_tr, Tok_Comment, Tok_String, Tok_Colon, Tok_Dot, Tok_LeftBrace, Tok_RightBrace, Tok_LeftParen, Tok_RightParen, Tok_Comma, Tok_Semicolon, - Tok_Integer, Tok_Plus, Tok_PlusPlus, Tok_PlusEq }; + Tok_Integer, Tok_Plus, Tok_PlusPlus, Tok_PlusEq, Tok_null }; class Scope { @@ -142,7 +142,11 @@ static int getToken() case 'c': if ( yyIdent == QLatin1String("class") ) return Tok_class; - break; + break; + case 'n': + if ( yyIdent == QLatin1String("null") ) + return Tok_null; + break; } } switch ( yyIdent.at(0).toLatin1() ) { @@ -382,9 +386,11 @@ static bool matchInteger( qlonglong *number) static bool matchStringOrNull(QString &s) { bool matches = matchString(s); - qlonglong num = 0; - if (!matches) matches = matchInteger(&num); - return matches && num == 0; + if (!matches) { + matches = (yyTok == Tok_null); + if (matches) yyTok = getToken(); + } + return matches; } /* -- cgit v0.12