Commit 23f337e6 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Bug 707567 - Asterisks in comment wrongly displayed for @code

parent 64ebc4f6
...@@ -191,6 +191,7 @@ static QCString g_delimiter; ...@@ -191,6 +191,7 @@ static QCString g_delimiter;
static int g_column; static int g_column;
static int g_fencedSize=0; static int g_fencedSize=0;
static bool g_nestedComment=0;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -6155,23 +6156,27 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) ...@@ -6155,23 +6156,27 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
docBlockName.at(1)='}'; docBlockName.at(1)='}';
} }
g_fencedSize=0; g_fencedSize=0;
g_nestedComment=FALSE;
BEGIN(DocCopyBlock); BEGIN(DocCopyBlock);
} }
<DocBlock>"<"{PRE}">" { <DocBlock>"<"{PRE}">" {
docBlock+=yytext; docBlock+=yytext;
docBlockName="<pre>"; docBlockName="<pre>";
g_fencedSize=0; g_fencedSize=0;
g_nestedComment=FALSE;
BEGIN(DocCopyBlock); BEGIN(DocCopyBlock);
} }
<DocBlock>{CMD}("verbatim"|"latexonly"|"htmlonly"|"xmlonly"|"manonly"|"dot"|"code")/[^a-z_A-Z0-9] { // verbatim command (which could contain nested comments!) <DocBlock>{CMD}("verbatim"|"latexonly"|"htmlonly"|"xmlonly"|"manonly"|"dot"|"code")/[^a-z_A-Z0-9] { // verbatim command (which could contain nested comments!)
docBlock+=yytext; docBlock+=yytext;
docBlockName=&yytext[1]; docBlockName=&yytext[1];
g_fencedSize=0; g_fencedSize=0;
g_nestedComment=FALSE;
BEGIN(DocCopyBlock); BEGIN(DocCopyBlock);
} }
<DocBlock>"~~~"[~]* { <DocBlock>"~~~"[~]* {
docBlock+=yytext; docBlock+=yytext;
g_fencedSize=yyleng; g_fencedSize=yyleng;
g_nestedComment=FALSE;
BEGIN(DocCopyBlock); BEGIN(DocCopyBlock);
} }
<DocBlock>{B}*"<code>" { <DocBlock>{B}*"<code>" {
...@@ -6179,6 +6184,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) ...@@ -6179,6 +6184,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
{ {
docBlock+=yytext; docBlock+=yytext;
docBlockName="<code>"; docBlockName="<code>";
g_nestedComment=FALSE;
BEGIN(DocCopyBlock); BEGIN(DocCopyBlock);
} }
else else
...@@ -6240,13 +6246,33 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) ...@@ -6240,13 +6246,33 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
docBlock+=indent; 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") if (docBlockName=="code")
{ {
QCString indent; QCString indent;
indent.fill(' ',computeIndent(yytext,0)-1); 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+"*"; docBlock+=indent+"*";
} }
else // remove * it is part of the comment block
{
indent.fill(' ',computeIndent(yytext,0));
docBlock+=indent;
}
}
else else
{ {
REJECT; REJECT;
...@@ -6263,6 +6289,14 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) ...@@ -6263,6 +6289,14 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
docBlock+=yytext; docBlock+=yytext;
} }
<DocCopyBlock>"/*"|"*/"|"//" { <DocCopyBlock>"/*"|"*/"|"//" {
if (yytext[1]=='*')
{
g_nestedComment=TRUE;
}
else if (yytext[0]=='*')
{
g_nestedComment=FALSE;
}
docBlock+=yytext; docBlock+=yytext;
} }
<DocCopyBlock>\n { // newline <DocCopyBlock>\n { // newline
......
...@@ -7,40 +7,34 @@ ...@@ -7,40 +7,34 @@
<para> <para>
<programlisting> <programlisting>
<codeline lineno="1"> <codeline lineno="1">
<highlight class="normal">*<sp/></highlight>
<highlight class="comment">#<sp/>comment<sp/>in<sp/>Python</highlight> <highlight class="comment">#<sp/>comment<sp/>in<sp/>Python</highlight>
<highlight class="normal"/> <highlight class="normal"/>
</codeline> </codeline>
<codeline lineno="2"> <codeline lineno="2">
<highlight class="normal">*<sp/></highlight> <highlight class="normal"/>
<highlight class="keyword">class<sp/></highlight> <highlight class="keyword">class<sp/></highlight>
<highlight class="normal">Python:</highlight> <highlight class="normal">Python:</highlight>
</codeline> </codeline>
<codeline lineno="3"> <codeline lineno="3">
<highlight class="normal">*<sp/><sp/><sp/></highlight> <highlight class="normal">
<sp/>
<sp/>
</highlight>
<highlight class="keywordflow">pass</highlight> <highlight class="keywordflow">pass</highlight>
<highlight class="normal"/>
</codeline>
<codeline lineno="4">
<highlight class="normal">*<sp/></highlight>
</codeline> </codeline>
</programlisting> </programlisting>
</para> </para>
<para> <para>
<programlisting> <programlisting>
<codeline> <codeline>
<highlight class="normal">*<sp/></highlight>
<highlight class="comment">//<sp/>comment<sp/>in<sp/>a<sp/>code<sp/>block</highlight> <highlight class="comment">//<sp/>comment<sp/>in<sp/>a<sp/>code<sp/>block</highlight>
<highlight class="normal"/> <highlight class="normal"/>
</codeline> </codeline>
<codeline> <codeline>
<highlight class="normal">*<sp/></highlight> <highlight class="normal"/>
<highlight class="keyword">class<sp/></highlight> <highlight class="keyword">class<sp/></highlight>
<highlight class="normal">Cpp<sp/>{};</highlight> <highlight class="normal">Cpp<sp/>{};</highlight>
</codeline> </codeline>
<codeline>
<highlight class="normal">*<sp/></highlight>
</codeline>
</programlisting> </programlisting>
</para> </para>
</detaileddescription> </detaileddescription>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment