# HG changeset patch # User David A. Holland # Date 1370914220 14400 # Node ID 27c9aafcaca1b846f04e64ac5f174355efe89f84 # Parent 7e64b1dd0a2653fcf7ba72095314b32bc5f842d2 Don't recognize comments within double-quote strings. Blah. diff -r 7e64b1dd0a26 -r 27c9aafcaca1 directive.c --- a/directive.c Mon Jun 10 20:19:49 2013 -0400 +++ b/directive.c Mon Jun 10 21:30:20 2013 -0400 @@ -60,6 +60,8 @@ { char *s, *t, *u = NULL; bool incomment = false; + bool inesc = false; + bool inquote = false; for (s = t = buf; *s; s++) { if (incomment) { @@ -68,9 +70,17 @@ incomment = false; } } else { - if (s[0] == '/' && s[1] == '*') { + if (!inquote && s[0] == '/' && s[1] == '*') { incomment = true; } else { + if (inesc) { + inesc = false; + } else if (s[0] == '\\') { + inesc = true; + } else if (s[0] == '"') { + inquote = !inquote; + } + if (t != s) { *t = *s; } diff -r 7e64b1dd0a26 -r 27c9aafcaca1 files.c --- a/files.c Mon Jun 10 20:19:49 2013 -0400 +++ b/files.c Mon Jun 10 21:30:20 2013 -0400 @@ -125,6 +125,7 @@ { size_t i; int incomment = 0; + bool inquote = false; for (i=start; i start) { dowrite(buf + start, pos - start); @@ -127,6 +129,16 @@ continue; } } + + if (incomment) { + /* nothing */ + } else if (inesc) { + inesc = false; + } else if (buf[pos] == '\\') { + inesc = true; + } else if (buf[pos] == '"') { + inquote = !inquote; + } } pos++;