From 7e9ac9f80784eef31fd84c3892115cffb1630f95 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Mon, 5 Oct 2020 21:33:05 +0200 Subject: Minor tweaks - lineCount() without arguments was unused - converted lineCount(...) into a macro with yytext and yyleng as arguments --- src/doctokenizer.l | 107 +++++++++++++++++++++++------------------------------ 1 file changed, 47 insertions(+), 60 deletions(-) diff --git a/src/doctokenizer.l b/src/doctokenizer.l index bf33e86..48d2fa4 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -84,8 +84,8 @@ static QStack g_lexerStack; static int g_yyLineNr = 0; -static void lineCount(); -static void lineCount(const char* text); +#define lineCount(s,len) do { for(int i=0;i\r /* skip carriage return */ ^{LISTITEM} { /* list item */ - lineCount(yytext); + lineCount(yytext,yyleng); QCString text=yytext; int dashPos = text.findRev('-'); g_token->isEnumList = text.at(dashPos+1)=='#'; @@ -514,7 +514,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio } else { - lineCount(yytext); + lineCount(yytext,yyleng); QCString text=yytext; static QRegExp re("[*+]"); int listPos = text.findRev(re); @@ -542,7 +542,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio } } {BLANK}*(\n|"\\ilinebr"){LISTITEM} { /* list item on next line */ - lineCount(yytext); + lineCount(yytext,yyleng); QCString text=extractPartAfterNewLine(yytext); int dashPos = text.findRev('-'); g_token->isEnumList = text.at(dashPos+1)=='#'; @@ -557,7 +557,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio } else { - lineCount(yytext); + lineCount(yytext,yyleng); QCString text=extractPartAfterNewLine(yytext); static QRegExp re("[*+]"); int markPos = text.findRev(re); @@ -568,14 +568,14 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio } } {BLANK}*(\n|"\\ilinebr"){OLISTITEM} { /* list item on next line */ - lineCount(yytext); + lineCount(yytext,yyleng); if (!g_markdownSupport || g_insidePre) { REJECT; } else { - lineCount(yytext); + lineCount(yytext,yyleng); QCString text=extractPartAfterNewLine(yytext); static QRegExp re("[1-9]"); int digitPos = text.find(re); @@ -587,13 +587,13 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio } } ^{ENDLIST} { /* end list */ - lineCount(yytext); + lineCount(yytext,yyleng); int dotPos = QCString(yytext).findRev('.'); g_token->indent = computeIndent(yytext,dotPos); return TK_ENDLIST; } {BLANK}*(\n|"\\ilinebr"){ENDLIST} { /* end list on next line */ - lineCount(yytext); + lineCount(yytext,yyleng); QCString text=extractPartAfterNewLine(yytext); int dotPos = text.findRev('.'); g_token->indent = computeIndent(text,dotPos); @@ -618,7 +618,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio return TK_COMMAND_SEL(); } {CMD}"n"\n { /* \n followed by real newline */ - lineCount(yytext); + lineCount(yytext,yyleng); //g_yyLineNr++; g_token->name = yytext+1; g_token->name = g_token->name.stripWhiteSpace(); @@ -718,7 +718,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio for (int i=value.length()-1;i>=0;i--) unput(value.at(i)); } {HTMLTAG} { /* html tag */ - lineCount(yytext); + lineCount(yytext,yyleng); handleHtmlTag(); return TK_HTMLTAG; } @@ -754,7 +754,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [\-+0-9] | {WORD1} | {WORD2} { /* function call */ - lineCount(yytext); + lineCount(yytext,yyleng); if (yytext[0]=='%') // strip % if present g_token->name = &yytext[1]; else @@ -781,7 +781,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio {BLANK}+ | {BLANK}*\n{BLANK}* { /* white space */ - lineCount(yytext); + lineCount(yytext,yyleng); g_token->chars=yytext; return TK_WHITESPACE; } @@ -794,24 +794,24 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio { REJECT; } - lineCount(yytext); + lineCount(yytext,yyleng); } ({BLANK}*\n)+{BLANK}*\n/{MLISTITEM} { /* skip trailing paragraph followed by new list item */ if (!g_markdownSupport || g_insidePre || g_autoListLevel==0) { REJECT; } - lineCount(yytext); + lineCount(yytext,yyleng); } ({BLANK}*\n)+{BLANK}*\n/{OLISTITEM} { /* skip trailing paragraph followed by new list item */ if (!g_markdownSupport || g_insidePre || g_autoListLevel==0) { REJECT; } - lineCount(yytext); + lineCount(yytext,yyleng); } ({BLANK}*\n)+{BLANK}*\n{BLANK}* { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->indent=computeIndent(yytext,(int)yyleng); int i; // put back the indentation (needed for list items) @@ -838,17 +838,17 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio BEGIN(St_Code); } {WS}*{CMD}"endcode" { - lineCount(yytext); + lineCount(yytext,yyleng); return RetVal_OK; } {WS}*"" { - lineCount(yytext); + lineCount(yytext,yyleng); return RetVal_OK; } [^\\@\n<]+ | \n | . { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } " [block]" { // the space is added in commentscan.l @@ -869,7 +869,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\\@\n$]+ | \n | . { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } {CMD}"endmanonly" { @@ -878,7 +878,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\\@\n$]+ | \n | . { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } {CMD}"endrtfonly" { @@ -887,7 +887,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\\@\n$]+ | \n | . { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } {CMD}"endlatexonly" { @@ -896,7 +896,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\\@\n]+ | \n | . { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } {CMD}"endxmlonly" { @@ -905,7 +905,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\\@\n]+ | \n | . { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } {CMD}"enddocbookonly" { @@ -914,7 +914,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\\@\n]+ | \n | . { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } {CMD}"endverbatim" { @@ -924,7 +924,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\\@\n]+ | \n | . { /* Verbatim text */ - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } {CMD}"enddot" { @@ -933,7 +933,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\\@\n]+ | \n | . { /* dot text */ - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } {CMD}("endmsc") { @@ -942,7 +942,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\\@\n]+ | \n | . { /* msc text */ - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } {BLANK}*"{"[^}]*"}" { // case 1: file name is specified as {filename} @@ -980,7 +980,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\\@\n]+ | \n | . { /* plantuml text */ - lineCount(yytext); + lineCount(yytext,yyleng); g_token->verb+=yytext; } "\"" { // quoted title @@ -1007,7 +1007,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio return TK_SYMBOL; } {HTMLTAG} { - lineCount(yytext); + lineCount(yytext,yyleng); } \n { /* new line => end of title */ unput(*yytext); @@ -1033,7 +1033,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [\-+0-9] | {WORD1} | {WORD2} { /* word */ - lineCount(yytext); + lineCount(yytext,yyleng); if (yytext[0]=='%') // strip % if present g_token->name = &yytext[1]; else @@ -1077,7 +1077,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio BEGIN(St_TitleV); } [^ \t\r\n]+ { // attribute value - lineCount(yytext); + lineCount(yytext,yyleng); g_token->chars = yytext; BEGIN(St_TitleN); return TK_WORD; @@ -1092,7 +1092,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio } {LABELID}{WS}? { // anchor - lineCount(yytext); + lineCount(yytext,yyleng); g_token->name = QCString(yytext).stripWhiteSpace(); return TK_WORD; } @@ -1141,7 +1141,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio return 0; } {WS}+"\""{WS}* { // white space following by quoted string - lineCount(yytext); + lineCount(yytext,yyleng); BEGIN(St_Ref2); } (\n|"\\ilinebr") { // new line @@ -1192,7 +1192,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio return TK_SYMBOL; } "\""|\n|"\\ilinebr" { /* " or \n => end of title */ - lineCount(yytext); + lineCount(yytext,yyleng); return 0; } {SPCMD1} | @@ -1233,7 +1233,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio return TK_WORD; } ({PHPTYPE}{BLANK}*("["{BLANK}*"]")*{BLANK}*"|"{BLANK}*)*{PHPTYPE}{BLANK}*("["{BLANK}*"]")*{WS}+("&")?"$"{LABELID} { - lineCount(yytext); + lineCount(yytext,yyleng); QCString params = yytext; int j = params.find('&'); int i = params.find('$'); @@ -1252,7 +1252,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio } {WS}*","{WS}* /* param separator */ {WS} { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->chars=yytext; return TK_WHITESPACE; } @@ -1261,7 +1261,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio } {WS}*","{WS}* {WS} { /* option separator */ - lineCount(yytext); + lineCount(yytext,yyleng); g_token->name+=","; } "}" { @@ -1297,7 +1297,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio return TK_WORD; } \n { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->name = g_token->name.stripWhiteSpace(); return TK_WORD; } @@ -1318,7 +1318,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio . (\n|"\\ilinebr") { - lineCount(yytext); + lineCount(yytext,yyleng); return 0; } @@ -1327,7 +1327,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio [^\n@\\<]+ {CMD}("<"|{CMD}) "<"{CAPTION}({WS}+{ATTRIB})*">" { - lineCount(yytext); + lineCount(yytext,yyleng); QCString tag=yytext; int s=tag.find("id="); if (s!=-1) // command has id attribute @@ -1431,7 +1431,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio . (\n|"\\ilinebr") {LABELID} { - lineCount(yytext); + lineCount(yytext,yyleng); g_secLabel = yytext; processSection(); BEGIN(St_Sections); @@ -1444,7 +1444,7 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio } [^\n]+ | [^\n]*\n { - lineCount(yytext); + lineCount(yytext,yyleng); g_secTitle = yytext; g_secTitle = g_secTitle.stripWhiteSpace(); if (g_secTitle.right(8)=="\\ilinebr") @@ -1465,14 +1465,14 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio g_token->name += yytext; } (\n|"\\ilinebr") { - lineCount(yytext); + lineCount(yytext,yyleng); g_token->name = g_token->name.stripWhiteSpace(); return TK_WORD; } /* Generic rules that work for all states */ <*>\n { - lineCount(yytext); + lineCount(yytext,yyleng); warn(g_fileName,g_yyLineNr,"Unexpected new line character"); } <*>"\\ilinebr" { @@ -1748,19 +1748,6 @@ int getDoctokinizerLineNr(void) return g_yyLineNr; } -static void lineCount() -{ - g_yyLineNr++; -} - -static void lineCount(const char* text) -{ - for (const char* c=text ; *c ; ++c ) - { - if (*c == '\n') g_yyLineNr++; - } -} - #if USE_STATE2STRING #include "doctokenizer.l.h" -- cgit v0.12