summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-08-05 07:45:32 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2020-08-05 08:00:35 (GMT)
commit3fa7a5eac154d97ce5cd4f0d87bfc75e05a20206 (patch)
tree42a9dbc95bdb744a4825a201cb59464caf8b846b /src
parent041215111a345199fcb52a26941e76c613a0b552 (diff)
parent23c71a3253f41a84a5624863b29fec69f87396d5 (diff)
downloadDoxygen-3fa7a5eac154d97ce5cd4f0d87bfc75e05a20206.zip
Doxygen-3fa7a5eac154d97ce5cd4f0d87bfc75e05a20206.tar.gz
Doxygen-3fa7a5eac154d97ce5cd4f0d87bfc75e05a20206.tar.bz2
Merge branch 'albert-github-feature/bug_py_empty_comment'
Diffstat (limited to 'src')
-rw-r--r--src/pyscanner.l68
-rw-r--r--src/util.cpp49
-rw-r--r--src/util.h1
3 files changed, 62 insertions, 56 deletions
diff --git a/src/pyscanner.l b/src/pyscanner.l
index 773391b..017cc03 100644
--- a/src/pyscanner.l
+++ b/src/pyscanner.l
@@ -141,7 +141,6 @@ static void initSpecialBlock(yyscan_t yyscanner);
static void searchFoundDef(yyscan_t yyscanner);
static void searchFoundClass(yyscan_t yyscanner);
static QCString findPackageScope(yyscan_t yyscanner,const char *fileName);
-static void stripIndentation(QCString &doc,const int indentationLevel);
static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size);
@@ -1253,9 +1252,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 +1267,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);
@@ -1522,55 +1527,6 @@ static inline int computeIndent(const char *s)
return col;
}
-// strip up to \a indentationLevel spaces from each line in \a doc (excluding the first line)
-static void stripIndentation(QCString &doc,const int indentationLevel)
-{
- if (indentationLevel <= 0) return; // nothing to strip
-
- // by stripping content the string will only become shorter so we write the results
- // back into the input string and then resize it at the end.
- char c;
- const char *src = doc.data();
- char *dst = doc.rawData();
- bool insideIndent = false; // skip the initial line from stripping
- int cnt = 0;
- while ((c=*src++)!=0)
- {
- // invariant: dst<=src
- switch(c)
- {
- case '\n':
- *dst++ = c;
- insideIndent = true;
- cnt = indentationLevel;
- break;
- case ' ':
- if (insideIndent)
- {
- if (cnt>0) // count down the spacing until the end of the indent
- {
- cnt--;
- }
- else // reached the end of the indent, start of the part of the line to keep
- {
- insideIndent = false;
- *dst++ = c;
- }
- }
- else // part after indent, copy to the output
- {
- *dst++ = c;
- }
- break;
- default:
- insideIndent = false;
- *dst++ = c;
- break;
- }
- }
- doc.resize(dst-doc.data()+1);
-}
-
static QCString findPackageScopeFromPath(yyscan_t yyscanner,const QCString &path)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
diff --git a/src/util.cpp b/src/util.cpp
index ebf3cf1..1fed382 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -7920,6 +7920,55 @@ QCString stripIndentation(const QCString &s)
return result.data();
}
+// strip up to \a indentationLevel spaces from each line in \a doc (excluding the first line)
+void stripIndentation(QCString &doc,const int indentationLevel)
+{
+ if (indentationLevel <= 0 || doc.isEmpty()) return; // nothing to strip
+
+ // by stripping content the string will only become shorter so we write the results
+ // back into the input string and then resize it at the end.
+ char c;
+ const char *src = doc.data();
+ char *dst = doc.rawData();
+ bool insideIndent = false; // skip the initial line from stripping
+ int cnt = 0;
+ while ((c=*src++)!=0)
+ {
+ // invariant: dst<=src
+ switch(c)
+ {
+ case '\n':
+ *dst++ = c;
+ insideIndent = true;
+ cnt = indentationLevel;
+ break;
+ case ' ':
+ if (insideIndent)
+ {
+ if (cnt>0) // count down the spacing until the end of the indent
+ {
+ cnt--;
+ }
+ else // reached the end of the indent, start of the part of the line to keep
+ {
+ insideIndent = false;
+ *dst++ = c;
+ }
+ }
+ else // part after indent, copy to the output
+ {
+ *dst++ = c;
+ }
+ break;
+ default:
+ insideIndent = false;
+ *dst++ = c;
+ break;
+ }
+ }
+ doc.resize(dst-doc.data()+1);
+}
+
bool fileVisibleInIndex(const FileDef *fd,bool &genSourceFile)
{
diff --git a/src/util.h b/src/util.h
index 65d164a..7de25ee 100644
--- a/src/util.h
+++ b/src/util.h
@@ -472,6 +472,7 @@ QCString processMarkup(const QCString &s);
bool protectionLevelVisible(Protection prot);
QCString stripIndentation(const QCString &s);
+void stripIndentation(QCString &doc,const int indentationLevel);
QCString getDotImageExtension(void);