Merged DMD commit c0d4f02e996e7913f729102a2c07eedcb015ba90:

4878 DDoc: Default arguments can break DDoc output

Merged from D2 into D1
This commit is contained in:
David Nadlinger
2011-04-23 17:43:25 +02:00
parent 6a77728578
commit f0cc2ed42e
3 changed files with 38 additions and 1 deletions

View File

@@ -363,6 +363,36 @@ void Module::gendocfile()
/****************************************************
* Having unmatched parentheses can hose the output of Ddoc,
* as the macros depend on properly nested parentheses.
* This function replaces all ( with $(LPAREN) and ) with $(RPAREN)
* to preserve text literally. This also means macros in the
* text won't be expanded.
*/
void escapeDdocString(OutBuffer *buf, unsigned start)
{
for (unsigned u = start; u < buf->offset; u++)
{
unsigned char c = buf->data[u];
switch(c)
{
case '(':
buf->remove(u, 1); //remove the (
buf->insert(u, "$(LPAREN)", 9); //insert this instead
u += 8; //skip over newly inserted macro
break;
case ')':
buf->remove(u, 1); //remove the )
buf->insert(u, "$(RPAREN)", 9); //insert this instead
u += 8; //skip over newly inserted macro
break;
}
}
}
/****************************************************
* Having unmatched parentheses can hose the output of Ddoc,
* as the macros depend on properly nested parentheses.
* Fix by replacing unmatched ( with $(LPAREN) and unmatched ) with $(RPAREN).
*/
void escapeStrayParenthesis(OutBuffer *buf, unsigned start, Loc loc)
@@ -852,7 +882,7 @@ void FuncDeclaration::toDocBuffer(OutBuffer *buf)
tp->toCBuffer(buf, &hgs);
}
buf->writeByte(')');
Parameter::argsToCBuffer(buf, &hgs, tf->parameters, tf->varargs);
Parameter::argsToCBuffer(buf, &hgs, tf ? tf->parameters : NULL, tf ? tf->varargs : 0);
buf->writestring(";\n");
highlightCode(NULL, this, buf, o);