summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Pastor <dg0yt@darc.de>2016-04-02 10:03:54 +0200
committerKai Pastor <dg0yt@darc.de>2016-04-12 19:18:33 +0000
commited2d5b7f44f9d0a25aa185d3843ee14366ffef7c (patch)
tree8e131dbc477d3ba19a3a6b46e10075d507da2c75
parentb2bede961d73ecc253f9bf6c61ccf3b5a8c12cb3 (diff)
downloadqttools-ed2d5b7f44f9d0a25aa185d3843ee14366ffef7c.tar.gz
lupdate: Treat NULL and Q_NULLPTR like literal 0
Task-number: QTBUG-34265 Change-Id: I2b69d7c6bc0514977cee9dd50a0c861e46dc589b Reviewed-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
-rw-r--r--src/linguist/lupdate/cpp.cpp8
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp9
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result14
3 files changed, 31 insertions, 0 deletions
diff --git a/src/linguist/lupdate/cpp.cpp b/src/linguist/lupdate/cpp.cpp
index f67abfae0..bf6d86de8 100644
--- a/src/linguist/lupdate/cpp.cpp
+++ b/src/linguist/lupdate/cpp.cpp
@@ -460,6 +460,8 @@ STRING(final);
STRING(friend);
STRING(namespace);
STRING(nullptr);
+STRING(Q_NULLPTR);
+STRING(NULL);
STRING(operator);
STRING(return);
STRING(struct);
@@ -682,7 +684,13 @@ CppParser::TokenType CppParser::getToken()
//qDebug() << "IDENT: " << yyWord;
switch (yyWord.unicode()[0].unicode()) {
+ case 'N':
+ if (yyWord == strNULL)
+ return Tok_Null;
+ break;
case 'Q':
+ if (yyWord == strQ_NULLPTR)
+ return Tok_Null;
if (yyWord == strQ_OBJECT)
return Tok_Q_OBJECT;
if (yyWord == strQ_SLOTS || yyWord == strQ_SIGNALS)
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
index d58ddf9fb..31783fd6a 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
@@ -507,3 +507,12 @@ class nullptrClass : public QObject
tr("%n car(s)", nullptr, 2);
}
};
+
+
+
+// QTBUG-34265: lupdate does not detect NULL and Q_NULLPTR as 0 when being passed as context
+void nullMacroInPlural()
+{
+ QObject::tr("%n NULL(s)", NULL, 3);
+ QObject::tr("%n Q_NULLPTR(s)", Q_NULLPTR, 3);
+}
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
index be9df15ca..4f301b2db 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
@@ -319,6 +319,20 @@ backslashed \ stuff.</source>
<numerusform></numerusform>
</translation>
</message>
+ <message numerus="yes">
+ <location filename="main.cpp" line="516"/>
+ <source>%n NULL(s)</source>
+ <translation type="unfinished">
+ <numerusform></numerusform>
+ </translation>
+ </message>
+ <message numerus="yes">
+ <location filename="main.cpp" line="517"/>
+ <source>%n Q_NULLPTR(s)</source>
+ <translation type="unfinished">
+ <numerusform></numerusform>
+ </translation>
+ </message>
<message>
<location filename="included.cpp" line="34"/>
<source>message from #included .cpp file</source>