Skip to content

Commit 603b2ad

Browse files
committed
issue #7923 source line numbers in warnings output by parser are off by 1
Explicit counting of the removed newlines at the beginning of a documenation block (markdown.cpp) so this number can be added to get a better line number in case of warnings.
1 parent 483b47d commit 603b2ad

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

src/fortranscanner.l

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2518,7 +2518,9 @@ static void handleCommentBlock(yyscan_t yyscanner,const QCString &doc,bool brief
25182518
int position=0;
25192519
bool needsEntry = FALSE;
25202520
Markdown markdown(yyextra->fileName,lineNr);
2521-
QCString processedDoc = Config_getBool(MARKDOWN_SUPPORT) ? markdown.process(doc) : doc;
2521+
int startNewlines = 0;
2522+
QCString processedDoc = Config_getBool(MARKDOWN_SUPPORT) ? markdown.process(doc,startNewlines) : doc;
2523+
lineNr += startNewlines;
25222524
while (yyextra->commentScanner.parseCommentBlock(
25232525
yyextra->thisParser,
25242526
yyextra->docBlockInBody ? yyextra->subrCurrent.back().get() : yyextra->current.get(),

src/markdown.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ QCString Markdown::detab(const QCString &s,int &refIndent)
24572457

24582458
//---------------------------------------------------------------------------
24592459

2460-
QCString Markdown::process(const QCString &input)
2460+
QCString Markdown::process(const QCString &input, int &startNewlines)
24612461
{
24622462
if (input.isEmpty()) return input;
24632463
int refIndent;
@@ -2488,7 +2488,7 @@ QCString Markdown::process(const QCString &input)
24882488
if (p)
24892489
{
24902490
while (*p==' ') p++; // skip over spaces
2491-
while (*p=='\n') p++; // skip over newlines
2491+
while (*p=='\n') {startNewlines++;p++;}; // skip over newlines
24922492
if (qstrncmp(p,"<br>",4)==0) p+=4; // skip over <br>
24932493
}
24942494
if (p>result.data())
@@ -2576,7 +2576,9 @@ void MarkdownOutlineParser::parseInput(const char *fileName,
25762576
Protection prot=Public;
25772577
bool needsEntry = FALSE;
25782578
int position=0;
2579-
QCString processedDocs = markdown.process(docs);
2579+
int startNewlines;
2580+
QCString processedDocs = markdown.process(docs,startNewlines);
2581+
lineNr += startNewlines;
25802582
while (p->commentScanner.parseCommentBlock(
25812583
this,
25822584
current.get(),

src/markdown.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Markdown
3333
{
3434
public:
3535
Markdown(const char *fileName,int lineNr,int indentLevel=0);
36-
QCString process(const QCString &input);
36+
QCString process(const QCString &input, int &startNewlines);
3737
QCString extractPageTitle(QCString &docs,QCString &id);
3838
void setIndentLevel(int level) { m_indentLevel = level; }
3939

src/pyscanner.l

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,9 @@ static void handleCommentBlock(yyscan_t yyscanner,const QCString &doc,bool brief
16311631
bool needsEntry;
16321632
int lineNr = brief ? yyextra->current->briefLine : yyextra->current->docLine;
16331633
Markdown markdown(yyextra->yyFileName,lineNr);
1634-
QCString processedDoc = Config_getBool(MARKDOWN_SUPPORT) ? markdown.process(doc) : doc;
1634+
int startNewlines = 0;
1635+
QCString processedDoc = Config_getBool(MARKDOWN_SUPPORT) ? markdown.process(doc,startNewlines) : doc;
1636+
lineNr += startNewlines;
16351637
while (yyextra->commentScanner.parseCommentBlock(
16361638
yyextra->thisParser,
16371639
(yyextra->docBlockInBody && yyextra->previous) ? yyextra->previous.get() : yyextra->current.get(),

src/scanner.l

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7020,7 +7020,9 @@ static void handleCommentBlock(yyscan_t yyscanner,const QCString &doc,bool brief
70207020
bool needsEntry=FALSE;
70217021
Markdown markdown(yyextra->yyFileName,lineNr);
70227022
QCString strippedDoc = stripIndentation(doc);
7023-
QCString processedDoc = Config_getBool(MARKDOWN_SUPPORT) ? markdown.process(strippedDoc) : strippedDoc;
7023+
int startNewlines = 0;
7024+
QCString processedDoc = Config_getBool(MARKDOWN_SUPPORT) ? markdown.process(strippedDoc,startNewlines) : strippedDoc;
7025+
lineNr += startNewlines;
70247026
while (yyextra->commentScanner.parseCommentBlock(
70257027
yyextra->thisParser,
70267028
yyextra->docBlockInBody && yyextra->previous ? yyextra->previous.get() : yyextra->current.get(),

src/vhdljjparser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ void VHDLOutlineParser::handleCommentBlock(const char *doc1, bool brief)
400400

401401

402402
Markdown markdown(p->yyFileName,p->iDocLine);
403-
QCString processedDoc = Config_getBool(MARKDOWN_SUPPORT) ? markdown.process(doc) : doc;
403+
int startNewlines = 0;
404+
QCString processedDoc = Config_getBool(MARKDOWN_SUPPORT) ? markdown.process(doc,startNewlines) : doc;
404405

405406
while (p->commentScanner.parseCommentBlock(
406407
p->thisParser,

0 commit comments

Comments
 (0)