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 2014/01/31 23:43:41 UTC
git commit: THRIFT-2338 First doctext wrongly interpreted as program
doctext in some cases
Updated Branches:
refs/heads/master b3e784994 -> 813749dc5
THRIFT-2338 First doctext wrongly interpreted as program doctext in some cases
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/813749dc
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/813749dc
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/813749dc
Branch: refs/heads/master
Commit: 813749dc50676c9d2ba778bf73bcb9bb872bd30c
Parents: b3e7849
Author: Jens Geyer <je...@apache.org>
Authored: Fri Jan 31 23:42:57 2014 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Fri Jan 31 23:42:57 2014 +0100
----------------------------------------------------------------------
compiler/cpp/src/globals.h | 3 ++-
compiler/cpp/src/logging.h | 46 +++++++++++++++++++++++++++++++++++++
compiler/cpp/src/main.cc | 5 ++++
compiler/cpp/src/main.h | 21 +----------------
compiler/cpp/src/parse/t_doc.h | 2 ++
compiler/cpp/src/thriftl.ll | 3 ++-
6 files changed, 58 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/813749dc/compiler/cpp/src/globals.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/globals.h b/compiler/cpp/src/globals.h
index 957e5d1..cf924f1 100644
--- a/compiler/cpp/src/globals.h
+++ b/compiler/cpp/src/globals.h
@@ -121,7 +121,8 @@ enum PROGDOCTEXT_STATUS {
INVALID = 0,
STILL_CANDIDATE = 1, // the text may or may not be the program doctext
ALREADY_PROCESSED = 2, // doctext has been used and is no longer available
- ABSOLUTELY_SURE = 3 // this is the program doctext
+ ABSOLUTELY_SURE = 3, // this is the program doctext
+ NO_PROGRAM_DOCTEXT = 4 // there is no program doctext
};
http://git-wip-us.apache.org/repos/asf/thrift/blob/813749dc/compiler/cpp/src/logging.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/logging.h b/compiler/cpp/src/logging.h
new file mode 100644
index 0000000..097469d
--- /dev/null
+++ b/compiler/cpp/src/logging.h
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef T_LOGGING_H
+#define T_LOGGING_H
+
+#include <string>
+
+/**
+ * Parse debugging output, used to print helpful info
+ */
+void pdebug(const char* fmt, ...);
+
+/**
+ * Parser warning
+ */
+void pwarning(int level, const char* fmt, ...);
+
+/**
+ * Print verbose output message
+ */
+void pverbose(const char* fmt, ...);
+
+/**
+ * Failure!
+ */
+void failure(const char* fmt, ...);
+
+
+#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/813749dc/compiler/cpp/src/main.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc
index bba4cdc..781db3b 100755
--- a/compiler/cpp/src/main.cc
+++ b/compiler/cpp/src/main.cc
@@ -406,6 +406,7 @@ void reset_program_doctext_info() {
}
g_program_doctext_lineno = 0;
g_program_doctext_status = INVALID;
+ pdebug("%s","program doctext set to INVALID");
}
/**
@@ -414,6 +415,10 @@ void reset_program_doctext_info() {
void declare_valid_program_doctext() {
if((g_program_doctext_candidate != NULL) && (g_program_doctext_status == STILL_CANDIDATE)) {
g_program_doctext_status = ABSOLUTELY_SURE;
+ pdebug("%s","program doctext set to ABSOLUTELY_SURE");
+ } else {
+ g_program_doctext_status = NO_PROGRAM_DOCTEXT;
+ pdebug("%s","program doctext set to NO_PROGRAM_DOCTEXT");
}
}
http://git-wip-us.apache.org/repos/asf/thrift/blob/813749dc/compiler/cpp/src/main.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/main.h b/compiler/cpp/src/main.h
index d554970..87af5f6 100644
--- a/compiler/cpp/src/main.h
+++ b/compiler/cpp/src/main.h
@@ -21,6 +21,7 @@
#define T_MAIN_H
#include <string>
+#include "logging.h"
#include "parse/t_const.h"
#include "parse/t_field.h"
@@ -38,26 +39,6 @@ int yyparse(void);
void yyerror(const char* fmt, ...);
/**
- * Parse debugging output, used to print helpful info
- */
-void pdebug(const char* fmt, ...);
-
-/**
- * Parser warning
- */
-void pwarning(int level, const char* fmt, ...);
-
-/**
- * Print verbose output message
- */
-void pverbose(const char* fmt, ...);
-
-/**
- * Failure!
- */
-void failure(const char* fmt, ...);
-
-/**
* Check simple identifier names
*/
void validate_simple_identifier(const char* identifier);
http://git-wip-us.apache.org/repos/asf/thrift/blob/813749dc/compiler/cpp/src/parse/t_doc.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_doc.h b/compiler/cpp/src/parse/t_doc.h
index a7c8cc9..2c63b5a 100644
--- a/compiler/cpp/src/parse/t_doc.h
+++ b/compiler/cpp/src/parse/t_doc.h
@@ -21,6 +21,7 @@
#define T_DOC_H
#include "globals.h"
+#include "logging.h"
/**
* Documentation stubs
@@ -36,6 +37,7 @@ class t_doc {
has_doc_ = true;
if( (g_program_doctext_lineno == g_doctext_lineno) && (g_program_doctext_status == STILL_CANDIDATE)) {
g_program_doctext_status = ALREADY_PROCESSED;
+ pdebug("%s","program doctext set to ALREADY_PROCESSED");
}
}
http://git-wip-us.apache.org/repos/asf/thrift/blob/813749dc/compiler/cpp/src/thriftl.ll
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll
index 4df4ccb..685bb54 100644
--- a/compiler/cpp/src/thriftl.ll
+++ b/compiler/cpp/src/thriftl.ll
@@ -384,10 +384,11 @@ literal_begin (['\"])
g_doctext[strlen(g_doctext) - 1] = '\0';
g_doctext = clean_up_doctext(g_doctext);
g_doctext_lineno = yylineno;
- if(g_program_doctext_candidate == NULL){
+ if( (g_program_doctext_candidate == NULL) && (g_program_doctext_status == INVALID)){
g_program_doctext_candidate = strdup(g_doctext);
g_program_doctext_lineno = g_doctext_lineno;
g_program_doctext_status = STILL_CANDIDATE;
+ pdebug("%s","program doctext set to STILL_CANDIDATE");
}
}
}