From 8f7394212564e1c466636d737fcb7abec5fdbfe6 Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 4 Aug 2020 13:23:41 +0200 Subject: Empty python comment gives problems In case we have an empty python comment like: `"""""""` (i.e. 6 double quotes) doxygen will crash in the pyscanner.l version of `stripIndentation`. ``` class Translator(nodes.NodeVisitor): """""" ## the var words_and_spaces = re.compile(r'\S+| +|\n') ``` In case of an empty comment we should not call `stripIndentation` and not place `\verbatim` / `\endverbatim` around the empty comment (the later would give an non-understandable empty comment block). An empty comment should be handled as no comment. Found by Fossies whilst generating documentation for Mercural 5.5). --- src/pyscanner.l | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pyscanner.l b/src/pyscanner.l index 773391b..701381b 100644 --- a/src/pyscanner.l +++ b/src/pyscanner.l @@ -1253,9 +1253,12 @@ STARTDOCSYMS "##" QCString actualDoc=yyextra->docBlock; if (!yyextra->docBlockSpecial) // legacy unformatted docstring { - stripIndentation(actualDoc,yyextra->commentIndent); - actualDoc.prepend("\\verbatim\n"); - actualDoc.append("\\endverbatim "); + if (!actualDoc.isEmpty()) + { + stripIndentation(actualDoc,yyextra->commentIndent); + actualDoc.prepend("\\verbatim\n"); + actualDoc.append("\\endverbatim "); + } } //printf("-------> yyextra->current=%p yyextra->bodyEntry=%p\n",yyextra->current,yyextra->bodyEntry); handleCommentBlock(yyscanner, actualDoc, FALSE); @@ -1265,9 +1268,12 @@ STARTDOCSYMS "##" QCString actualDoc=yyextra->docBlock; if (!yyextra->docBlockSpecial) // legacy unformatted docstring { - stripIndentation(actualDoc,yyextra->commentIndent); - actualDoc.prepend("\\verbatim\n"); - actualDoc.append("\\endverbatim "); + if (!actualDoc.isEmpty()) + { + stripIndentation(actualDoc,yyextra->commentIndent); + actualDoc.prepend("\\verbatim\n"); + actualDoc.append("\\endverbatim "); + } } actualDoc.prepend("\\namespace "+yyextra->moduleScope+" "); handleCommentBlock(yyscanner, actualDoc, FALSE); -- cgit v0.12