comparison files.c @ 128:1cda505ddc78

Don't expand macros within character constants.
author David A. Holland
date Fri, 14 Jun 2013 20:59:24 -0400
parents 1e7144176a42
children ed45f2d8d3bc
comparison
equal deleted inserted replaced
127:a0a86380456e 128:1cda505ddc78
125 findeol(const char *buf, size_t start, size_t limit) 125 findeol(const char *buf, size_t start, size_t limit)
126 { 126 {
127 size_t i; 127 size_t i;
128 int incomment = 0; 128 int incomment = 0;
129 bool inquote = false; 129 bool inquote = false;
130 char quote = '\0';
130 131
131 for (i=start; i<limit; i++) { 132 for (i=start; i<limit; i++) {
132 if (incomment) { 133 if (incomment) {
133 if (i+1 < limit && buf[i] == '*' && buf[i+1] == '/') { 134 if (i+1 < limit && buf[i] == '*' && buf[i+1] == '/') {
134 i++; 135 i++;
137 } else if (!inquote && i+1 < limit && 138 } else if (!inquote && i+1 < limit &&
138 buf[i] == '/' && buf[i+1] == '*') { 139 buf[i] == '/' && buf[i+1] == '*') {
139 i++; 140 i++;
140 incomment = 1; 141 incomment = 1;
141 } else if (i+1 < limit && 142 } else if (i+1 < limit &&
142 buf[i] == '\\' && buf[i+1] == '"') { 143 buf[i] == '\\' && buf[i+1] != '\n') {
143 i++; 144 i++;
144 } else if (buf[i] == '"') { 145 } else if (!inquote && (buf[i] == '"' || buf[i] == '\'')) {
145 inquote = !inquote; 146 inquote = true;
147 quote = buf[i];
148 } else if (inquote && buf[i] == quote) {
149 inquote = false;
146 } else if (buf[i] == '\n') { 150 } else if (buf[i] == '\n') {
147 return i; 151 return i;
148 } 152 }
149 } 153 }
150 return limit; 154 return limit;