mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-03-13 23:51:49 +01:00
Merged DMD commit c0d4f02e996e7913f729102a2c07eedcb015ba90:
4878 DDoc: Default arguments can break DDoc output Merged from D2 into D1
This commit is contained in:
32
dmd/doc.c
32
dmd/doc.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user