Skip to content

Commit

Permalink
Fix Issue 13212 - Windows line endings handled incorrectly by ddoc ma…
Browse files Browse the repository at this point in the history
…cros

Handle \r as \n in macro definitions to prevent a trailing carriage
return on a macro with an empty line following it.
  • Loading branch information
ntrel committed Jul 29, 2014
1 parent ecb09de commit 35735aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/doc.c
Expand Up @@ -1779,6 +1779,7 @@ void DocComment::parseMacros(Escape **pescapetable, Macro **pmacrotable, const u
p++;
continue;

case '\r':
case '\n':
p++;
goto Lcont;
Expand Down Expand Up @@ -1843,14 +1844,10 @@ void DocComment::parseMacros(Escape **pescapetable, Macro **pmacrotable, const u
textstart = p;

Ltext:
while (p < pend && *p != '\n')
while (p < pend && *p != '\r' && *p != '\n')
p++;
textlen = p - textstart;

// Remove trailing \r if there is one
if (p > m && p[-1] == '\r')
textlen--;

p++;
//printf("p = %p, pend = %p\n", p, pend);

Expand All @@ -1859,8 +1856,8 @@ void DocComment::parseMacros(Escape **pescapetable, Macro **pmacrotable, const u

Lskipline:
// Ignore this line
while (p < pend && *p++ != '\n')
;
while (p < pend && *p != '\r' && *p != '\n')
p++;
}
Ldone:
if (namelen)
Expand Down
4 changes: 3 additions & 1 deletion test/compilable/extra-files/ddoc3.ddoc
@@ -1 +1,3 @@
HELLO = world
HELLO = world

UNUSED=unused

0 comments on commit 35735aa

Please sign in to comment.