THRIFT-2320 Program level doctext does not get attached by parser
Patch: Craig Peterson & Jens Geyer
diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc
index 4ce22b4..bba4cdc 100755
--- a/compiler/cpp/src/main.cc
+++ b/compiler/cpp/src/main.cc
@@ -146,6 +146,13 @@
*/
int g_doctext_lineno;
+/**
+ * The First doctext comment
+ */
+char* g_program_doctext_candidate;
+int g_program_doctext_lineno = 0;
+PROGDOCTEXT_STATUS g_program_doctext_status = INVALID;
+
/**
* Whether or not negative field keys are accepted.
*/
@@ -390,6 +397,27 @@
}
/**
+ * Reset program doctext information after processing a file
+ */
+void reset_program_doctext_info() {
+ if(g_program_doctext_candidate != NULL) {
+ free(g_program_doctext_candidate);
+ g_program_doctext_candidate = NULL;
+ }
+ g_program_doctext_lineno = 0;
+ g_program_doctext_status = INVALID;
+}
+
+/**
+ * We are sure the program doctext candidate is really the program doctext.
+ */
+void declare_valid_program_doctext() {
+ if((g_program_doctext_candidate != NULL) && (g_program_doctext_status == STILL_CANDIDATE)) {
+ g_program_doctext_status = ABSOLUTELY_SURE;
+ }
+}
+
+/**
* Cleans up text commonly found in doxygen-like comments
*
* Warning: if you mix tabs and spaces in a non-uniform way,
@@ -911,6 +939,9 @@
parse(*iter, program);
}
+ // reset program doctext status before parsing a new file
+ reset_program_doctext_info();
+
// Parse the program file
g_parse_mode = PROGRAM;
g_program = program;