Re: "\c \e foo bar" = bug? [PATCH]
Matthew Woehlke <[email protected]>
| Newsgroups | gmane.text.doxygen.devel |
|---|---|
| Message-ID | <[email protected]> |
Matthew Woehlke wrote: > Dimitri van Heesch wrote: >> On 3/7/07, Matthew Woehlke wrote: >>> Is this a bug? >>> >>> "\c \e foo bar" == "<tt><i>foo</i> bar</tt>" >>> >>> Shouldn't it be: >>> >>> "<tt><i>foo</i></tt> bar"? >> That would indeed be more logical. >> >>> ...and any pointers where I can go tweak to fix it? >> src/docparser.cpp is where the commands are handled, in particular >> look at defaultHandleToken() and handleStyleArgument() > > Thanks. Oh, and I saw your reply to Tim, I'll go file a Real Bug Report > now... hopefully I can get a patch in a few days too. I'm still on 1.4.7 > because I want to use the @li2 I wrote. (Btw, what ever happened with > that patch I sent?) Here's a patch; I think it qualifies as "an ugly hack" :-). I added this to http://bugzilla.gnome.org/show_bug.cgi?id=418615 as well, but it would be great if other doxygen hackers could take a look. Be sure to add RetVal_Nested to doctokenizer.h also (yeah, I'm lazy, diff -r would have pulled in all my other changes also so I left out the one-liner). Thanks again for the pointer, Dimitri, you were spot-on! I also touched handleCommand as well although I'm not sure that is necessary. -- Matthew Caution: keep out of reach of adults. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Doxygen-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/doxygen-develop
doxygen_multi.patch
(text/x-patch, 5.7 KB)
--- doxygen-1.4.7_old/src/docparser.cpp 2006-05-07 13:02:30.000000000 -0500
+++ doxygen-1.4.7/src/docparser.cpp 2007-03-15 13:28:51.000000000 -0500
@@ -662,7 +662,11 @@
static int handleStyleArgument(DocNode *parent,QList<DocNode> &children,
const QString &cmdName)
{
- DBG(("handleStyleArgument(%s)\n",cmdName.data()));
+ static int nest=0;
+ static int reparse_tok=0;
+ bool first=(nest==0?TRUE:FALSE);
+ int myNest = ++nest;
+ DBG(("handleStyleArgument(%s), nest=%d\n",cmdName.data(),nest));
QString tokenName = g_token->name;
int tok=doctokenizerYYlex();
if (tok!=TK_WHITESPACE)
@@ -683,7 +687,9 @@
g_token->name.find(specialChar)!=-1)
{
// special character that ends the markup command
- return tok;
+ reparse_tok=tok;
+ DBG(("handleStyleArgument(%s) reparse tok=%x nest=%d\n",cmdName.data(),tok,nest));
+ return (nest > 1) ? RetVal_Nested : tok;
}
if (!defaultHandleToken(parent,tok,children))
{
@@ -711,8 +717,25 @@
}
break;
}
+ else if (nest > myNest) // stop parsing if a nested command already ate all tokens
+ {
+ break;
+ }
+ }
+ if (first) nest=0; // if we are first, reset nest when we exit
+ if (reparse_tok)
+ {
+ DBG(("handleStyleArgument(%s) reparse tok=%x first=%d\n",cmdName.data(),tok,first));
+ // if the upper level found a special end-markup token, we must propogate it
+ if (first)
+ {
+ tok=reparse_tok;
+ reparse_tok=0;
}
- DBG(("handleStyleArgument(%s) end tok=%x\n",cmdName.data(),tok));
+ return first?tok:RetVal_Nested;
+ }
+ DBG(("handleStyleArgument(%s) end tok=%x nest=%d\n",cmdName.data(),tok,nest));
+ if (nest) return RetVal_Nested;
return (tok==TK_NEWPARA || tok==TK_LISTITEM || tok==TK_ENDLIST
) ? tok : RetVal_OK;
}
@@ -1014,7 +1037,7 @@
children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Italic,TRUE));
tok=handleStyleArgument(parent,children,tokenName);
children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Italic,FALSE));
- if (tok!=TK_WORD) children.append(new DocWhiteSpace(parent," "));
+ if (tok!=TK_WORD&&tok!=RetVal_Nested) children.append(new DocWhiteSpace(parent," "));
if (tok==TK_NEWPARA) goto handlepara;
else if (tok==TK_WORD || tok==TK_HTMLTAG)
{
@@ -1028,7 +1051,7 @@
children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Bold,TRUE));
tok=handleStyleArgument(parent,children,tokenName);
children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Bold,FALSE));
- if (tok!=TK_WORD) children.append(new DocWhiteSpace(parent," "));
+ if (tok!=TK_WORD&&tok!=RetVal_Nested) children.append(new DocWhiteSpace(parent," "));
if (tok==TK_NEWPARA) goto handlepara;
else if (tok==TK_WORD || tok==TK_HTMLTAG)
{
@@ -1042,7 +1065,7 @@
children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Code,TRUE));
tok=handleStyleArgument(parent,children,tokenName);
children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Code,FALSE));
- if (tok!=TK_WORD) children.append(new DocWhiteSpace(parent," "));
+ if (tok!=TK_WORD&&tok!=RetVal_Nested) children.append(new DocWhiteSpace(parent," "));
if (tok==TK_NEWPARA) goto handlepara;
else if (tok==TK_WORD || tok==TK_HTMLTAG)
{
@@ -4123,19 +4166,22 @@
m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,TRUE));
retval=handleStyleArgument(this,m_children,cmdName);
m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,FALSE));
- if (retval!=TK_WORD) m_children.append(new DocWhiteSpace(this," "));
+ if (retval!=TK_WORD&&retval!=RetVal_Nested) m_children.append(new DocWhiteSpace(this," "));
+ if (retval==RetVal_Nested) retval=RetVal_OK;
break;
case CMD_BOLD:
m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Bold,TRUE));
retval=handleStyleArgument(this,m_children,cmdName);
m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Bold,FALSE));
- if (retval!=TK_WORD) m_children.append(new DocWhiteSpace(this," "));
+ if (retval!=TK_WORD&&retval!=RetVal_Nested) m_children.append(new DocWhiteSpace(this," "));
+ if (retval==RetVal_Nested) retval=RetVal_OK;
break;
case CMD_CODE:
m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Code,TRUE));
retval=handleStyleArgument(this,m_children,cmdName);
m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Code,FALSE));
- if (retval!=TK_WORD) m_children.append(new DocWhiteSpace(this," "));
+ if (retval!=TK_WORD&&retval!=RetVal_Nested) m_children.append(new DocWhiteSpace(this," "));
+ if (retval==RetVal_Nested) retval=RetVal_OK;
break;
case CMD_BSLASH:
m_children.append(new DocSymbol(this,DocSymbol::BSlash));
@@ -4700,7 +4752,8 @@
m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,TRUE));
retval=handleStyleArgument(this,m_children,paramName);
m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,FALSE));
- if (retval!=TK_WORD) m_children.append(new DocWhiteSpace(this," "));
+ if (retval!=TK_WORD&&retval!=RetVal_Nested) m_children.append(new DocWhiteSpace(this," "));
+ if (retval==RetVal_Nested) retval=RetVal_OK;
}
else
{