diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index 922bbfcdc..895118363 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -26,6 +26,7 @@ extern "C" { extern int cparse_line; extern int cparse_cplusplus; extern int cparse_start_line; + extern int scan_doxygen_comments; extern void Swig_cparse_cplusplus(int); extern void scanner_file(File *); diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 66a570a95..44af1069b 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -46,6 +46,9 @@ static int last_brace = 0; static int last_id = 0; static int rename_active = 0; +/* Doxygen comments scanning */ +int scan_doxygen_comments = 1; + /* ----------------------------------------------------------------------------- * Swig_cparse_cplusplus() * ----------------------------------------------------------------------------- */ @@ -337,15 +340,17 @@ static int yylook(void) { if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) { Scanner_locator(scan, cmt); } - if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { - /* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ - yylval.str = NewString(loc); - return DOXYGENPOSTSTRING; - } - if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { - /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ - yylval.str = NewString(loc); - return DOXYGENSTRING; + if (scan_doxygen_comments) { /* else just skip this node, to avoid crashes in parser module*/ + if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { + /* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ + yylval.str = NewString(loc); + return DOXYGENPOSTSTRING; + } + if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { + /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ + yylval.str = NewString(loc); + return DOXYGENSTRING; + } } } break; diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 39028cfe7..ffba04884 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -63,7 +63,6 @@ static Node **class_decl = NULL; /* ----------------------------------------------------------------------------- * Doxygen Comment Globals and Assist Functions * ----------------------------------------------------------------------------- */ -int parseComments = 1; /* set this to activate Doxygen uptake into the parse tree */ String *currentComment; /* Location of the stored Doxygen Comment */ String *currentPostComment; /* Location of the stored Doxygen Post-Comment */ String *currentCComment; /* Location of the stored C Comment */ @@ -107,7 +106,7 @@ static Node *new_node(const_String_or_char_ptr tag) { set_nodeType(n,tag); Setfile(n,cparse_file); Setline(n,cparse_line); - if(parseComments){ + if(scan_doxygen_comments){ /* Sets any post comments to the previous node */ if(previousNode != NULL && currentPostComment != 0){ String *copyPostComment = Copy(currentPostComment);