Mercurial > ~dholland > hg > tradcpp > index.cgi
diff macro.c @ 128:1cda505ddc78
Don't expand macros within character constants.
author | David A. Holland |
---|---|
date | Fri, 14 Jun 2013 20:59:24 -0400 |
parents | c13f36775fe8 |
children | 2e1496dd96c4 |
line wrap: on
line diff
--- a/macro.c Wed Jun 12 10:52:56 2013 -0400 +++ b/macro.c Fri Jun 14 20:59:24 2013 -0400 @@ -1066,6 +1066,7 @@ char *s; size_t x; bool inquote = false; + char quote = '\0'; while (len > 0) { x = strspn(buf, ws); @@ -1128,14 +1129,18 @@ continue; } - if (len > 1 && buf[0] == '\\' && buf[1] == '"') { + if (len > 1 && buf[0] == '\\' && + (buf[1] == '"' || buf[1] == '\'')) { expand_got_other(es, p, buf, 2); buf += 2; len -= 2; continue; } - if (buf[0] == '"') { - inquote = !inquote; + if (!inquote && (buf[0] == '"' || buf[0] == '\'')) { + inquote = true; + quote = buf[0]; + } else if (inquote && buf[0] == quote) { + inquote = false; } expand_got_other(es, p, buf, 1);