Mercurial > ~dholland > hg > tradcpp > index.cgi
comparison output.c @ 128:1cda505ddc78
Don't expand macros within character constants.
author | David A. Holland |
---|---|
date | Fri, 14 Jun 2013 20:59:24 -0400 |
parents | 343af355df1b |
children | ed45f2d8d3bc |
comparison
equal
deleted
inserted
replaced
127:a0a86380456e | 128:1cda505ddc78 |
---|---|
99 filter_output(const char *buf, size_t len) | 99 filter_output(const char *buf, size_t len) |
100 { | 100 { |
101 size_t pos, start; | 101 size_t pos, start; |
102 bool inesc = false; | 102 bool inesc = false; |
103 bool inquote = false; | 103 bool inquote = false; |
104 char quote = '\0'; | |
104 | 105 |
105 start = 0; | 106 start = 0; |
106 for (pos = 0; pos < len - 1; pos++) { | 107 for (pos = 0; pos < len - 1; pos++) { |
107 if (!inquote && buf[pos] == '/' && buf[pos+1] == '*') { | 108 if (!inquote && buf[pos] == '/' && buf[pos+1] == '*') { |
108 if (!incomment) { | 109 if (!incomment) { |
134 /* nothing */ | 135 /* nothing */ |
135 } else if (inesc) { | 136 } else if (inesc) { |
136 inesc = false; | 137 inesc = false; |
137 } else if (buf[pos] == '\\') { | 138 } else if (buf[pos] == '\\') { |
138 inesc = true; | 139 inesc = true; |
139 } else if (buf[pos] == '"') { | 140 } else if (!inquote && (buf[pos] == '"' || buf[pos] == '\'')) { |
140 inquote = !inquote; | 141 inquote = true; |
142 quote = buf[pos]; | |
143 } else if (inquote && buf[pos] == quote) { | |
144 inquote = false; | |
141 } | 145 } |
142 } | 146 } |
143 pos++; | 147 pos++; |
144 | 148 |
145 if (pos > start) { | 149 if (pos > start) { |