summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2013-09-06 11:54:54 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2013-09-06 12:02:18 (GMT)
commit23f337e64b95d3fa08f32980c866669b190c872f (patch)
treefac1cf7e63cc686cb2721d4ca0aa358e8cfbf321
parent64ebc4f67d56b93f512c1ed935f1d9188cfbf554 (diff)
downloadDoxygen-23f337e64b95d3fa08f32980c866669b190c872f.zip
Doxygen-23f337e64b95d3fa08f32980c866669b190c872f.tar.gz
Doxygen-23f337e64b95d3fa08f32980c866669b190c872f.tar.bz2
Bug 707567 - Asterisks in comment wrongly displayed for @code
-rw-r--r--src/scanner.l40
-rw-r--r--testing/014/indexpage.xml18
2 files changed, 43 insertions, 15 deletions
diff --git a/src/scanner.l b/src/scanner.l
index 40f653a..9e2cfd5 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -191,6 +191,7 @@ static QCString g_delimiter;
static int g_column;
static int g_fencedSize=0;
+static bool g_nestedComment=0;
//-----------------------------------------------------------------------------
@@ -6155,23 +6156,27 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
docBlockName.at(1)='}';
}
g_fencedSize=0;
+ g_nestedComment=FALSE;
BEGIN(DocCopyBlock);
}
<DocBlock>"<"{PRE}">" {
docBlock+=yytext;
docBlockName="<pre>";
g_fencedSize=0;
+ g_nestedComment=FALSE;
BEGIN(DocCopyBlock);
}
<DocBlock>{CMD}("verbatim"|"latexonly"|"htmlonly"|"xmlonly"|"manonly"|"dot"|"code")/[^a-z_A-Z0-9] { // verbatim command (which could contain nested comments!)
docBlock+=yytext;
docBlockName=&yytext[1];
g_fencedSize=0;
+ g_nestedComment=FALSE;
BEGIN(DocCopyBlock);
}
<DocBlock>"~~~"[~]* {
docBlock+=yytext;
g_fencedSize=yyleng;
+ g_nestedComment=FALSE;
BEGIN(DocCopyBlock);
}
<DocBlock>{B}*"<code>" {
@@ -6179,6 +6184,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
{
docBlock+=yytext;
docBlockName="<code>";
+ g_nestedComment=FALSE;
BEGIN(DocCopyBlock);
}
else
@@ -6240,12 +6246,32 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
docBlock+=indent;
}
}
-<DocCopyBlock>^{B}*+"*"/{BN}* { // start of a comment line
+<DocCopyBlock>^{B}*"*"+/{BN}+"*"{BN}* { // start of a comment line with two *'s
if (docBlockName=="code")
{
QCString indent;
- indent.fill(' ',computeIndent(yytext,0)-1);
- docBlock+=indent+"*";
+ indent.fill(' ',computeIndent(yytext,0));
+ docBlock+=indent;
+ }
+ else
+ {
+ REJECT;
+ }
+ }
+<DocCopyBlock>^{B}*"*"+/{BN}* { // start of a comment line with one *
+ if (docBlockName=="code")
+ {
+ QCString indent;
+ if (g_nestedComment) // keep * it is part of the code
+ {
+ indent.fill(' ',computeIndent(yytext,-1));
+ docBlock+=indent+"*";
+ }
+ else // remove * it is part of the comment block
+ {
+ indent.fill(' ',computeIndent(yytext,0));
+ docBlock+=indent;
+ }
}
else
{
@@ -6263,6 +6289,14 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
docBlock+=yytext;
}
<DocCopyBlock>"/*"|"*/"|"//" {
+ if (yytext[1]=='*')
+ {
+ g_nestedComment=TRUE;
+ }
+ else if (yytext[0]=='*')
+ {
+ g_nestedComment=FALSE;
+ }
docBlock+=yytext;
}
<DocCopyBlock>\n { // newline
diff --git a/testing/014/indexpage.xml b/testing/014/indexpage.xml
index 9662b9c..c2fe57a 100644
--- a/testing/014/indexpage.xml
+++ b/testing/014/indexpage.xml
@@ -7,40 +7,34 @@
<para>
<programlisting>
<codeline lineno="1">
- <highlight class="normal">*<sp/></highlight>
<highlight class="comment">#<sp/>comment<sp/>in<sp/>Python</highlight>
<highlight class="normal"/>
</codeline>
<codeline lineno="2">
- <highlight class="normal">*<sp/></highlight>
+ <highlight class="normal"/>
<highlight class="keyword">class<sp/></highlight>
<highlight class="normal">Python:</highlight>
</codeline>
<codeline lineno="3">
- <highlight class="normal">*<sp/><sp/><sp/></highlight>
+ <highlight class="normal">
+ <sp/>
+ <sp/>
+ </highlight>
<highlight class="keywordflow">pass</highlight>
- <highlight class="normal"/>
- </codeline>
- <codeline lineno="4">
- <highlight class="normal">*<sp/></highlight>
</codeline>
</programlisting>
</para>
<para>
<programlisting>
<codeline>
- <highlight class="normal">*<sp/></highlight>
<highlight class="comment">//<sp/>comment<sp/>in<sp/>a<sp/>code<sp/>block</highlight>
<highlight class="normal"/>
</codeline>
<codeline>
- <highlight class="normal">*<sp/></highlight>
+ <highlight class="normal"/>
<highlight class="keyword">class<sp/></highlight>
<highlight class="normal">Cpp<sp/>{};</highlight>
</codeline>
- <codeline>
- <highlight class="normal">*<sp/></highlight>
- </codeline>
</programlisting>
</para>
</detaileddescription>