comparison directive.c @ 81:27c9aafcaca1

Don't recognize comments within double-quote strings. Blah.
author David A. Holland
date Mon, 10 Jun 2013 21:30:20 -0400
parents 123168887da8
children 05a94332f08b
comparison
equal deleted inserted replaced
80:7e64b1dd0a26 81:27c9aafcaca1
58 void 58 void
59 uncomment(char *buf) 59 uncomment(char *buf)
60 { 60 {
61 char *s, *t, *u = NULL; 61 char *s, *t, *u = NULL;
62 bool incomment = false; 62 bool incomment = false;
63 bool inesc = false;
64 bool inquote = false;
63 65
64 for (s = t = buf; *s; s++) { 66 for (s = t = buf; *s; s++) {
65 if (incomment) { 67 if (incomment) {
66 if (s[0] == '*' && s[1] == '/') { 68 if (s[0] == '*' && s[1] == '/') {
67 s++; 69 s++;
68 incomment = false; 70 incomment = false;
69 } 71 }
70 } else { 72 } else {
71 if (s[0] == '/' && s[1] == '*') { 73 if (!inquote && s[0] == '/' && s[1] == '*') {
72 incomment = true; 74 incomment = true;
73 } else { 75 } else {
76 if (inesc) {
77 inesc = false;
78 } else if (s[0] == '\\') {
79 inesc = true;
80 } else if (s[0] == '"') {
81 inquote = !inquote;
82 }
83
74 if (t != s) { 84 if (t != s) {
75 *t = *s; 85 *t = *s;
76 } 86 }
77 if (!strchr(ws, *t)) { 87 if (!strchr(ws, *t)) {
78 u = t; 88 u = t;