You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2015/12/08 21:07:06 UTC
thrift git commit: THRIFT-3477 Parser fails on enum item that starts
with 'E' letter and continues with number Client: Compiler (general) Patch:
Jens Geyer
Repository: thrift
Updated Branches:
refs/heads/master 3143bfbe1 -> 5eed3a161
THRIFT-3477 Parser fails on enum item that starts with 'E' letter and continues with number
Client: Compiler (general)
Patch: Jens Geyer
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/5eed3a16
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/5eed3a16
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/5eed3a16
Branch: refs/heads/master
Commit: 5eed3a161fc4750ac7db5651373c5c2ece709fe6
Parents: 3143bfb
Author: Jens Geyer <je...@apache.org>
Authored: Tue Dec 8 01:32:12 2015 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Tue Dec 8 21:05:52 2015 +0100
----------------------------------------------------------------------
compiler/cpp/src/thriftl.ll | 11 ++++++-----
test/ConstantsDemo.thrift | 2 ++
test/EnumTest.thrift | 5 +++++
3 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/5eed3a16/compiler/cpp/src/thriftl.ll
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll
index 76acda1..7e68dbc 100644
--- a/compiler/cpp/src/thriftl.ll
+++ b/compiler/cpp/src/thriftl.ll
@@ -325,11 +325,6 @@ literal_begin (['\"])
return tok_int_constant;
}
-{dubconstant} {
- yylval.dconst = atof(yytext);
- return tok_dub_constant;
-}
-
{identifier} {
yylval.id = strdup(yytext);
return tok_identifier;
@@ -340,6 +335,12 @@ literal_begin (['\"])
return tok_st_identifier;
}
+{dubconstant} {
+ /* Deliberately placed after identifier, since "e10" is NOT a double literal (THRIFT-3477) */
+ yylval.dconst = atof(yytext);
+ return tok_dub_constant;
+}
+
{literal_begin} {
char mark = yytext[0];
std::string result;
http://git-wip-us.apache.org/repos/asf/thrift/blob/5eed3a16/test/ConstantsDemo.thrift
----------------------------------------------------------------------
diff --git a/test/ConstantsDemo.thrift b/test/ConstantsDemo.thrift
index 9a71ac8..0e3c1d9 100644
--- a/test/ConstantsDemo.thrift
+++ b/test/ConstantsDemo.thrift
@@ -47,6 +47,8 @@ const double GEn_DUB = 325.532
const double GEn_DU = 085.2355
const string GEN_STRING = "asldkjasfd"
+const double e10 = 1e10 // fails with 0.9.3 and earlier
+
const map<i32,i32> GEN_MAP = { 35532 : 233, 43523 : 853 }
const list<i32> GEN_LIST = [ 235235, 23598352, 3253523 ]
http://git-wip-us.apache.org/repos/asf/thrift/blob/5eed3a16/test/EnumTest.thrift
----------------------------------------------------------------------
diff --git a/test/EnumTest.thrift b/test/EnumTest.thrift
index 17af408..f38cec3 100644
--- a/test/EnumTest.thrift
+++ b/test/EnumTest.thrift
@@ -66,6 +66,11 @@ enum MyEnum4 {
// represented with an i32.
}
+enum MyEnum5 {
+ e1 // fails with 0.9.3 and earlier
+ e2 = 42 // fails with 0.9.3 and earlier
+}
+
struct MyStruct {
1: MyEnum2 me2_2 = MyEnum1.ME2_2
2: MyEnum3 me3_n2 = MyEnum3.ME3_N2