src/ccodegen.c

changeset 28
1be8ea902ef4
parent 26
05c3c6842aef
child 29
ec6e97454e64
--- a/src/ccodegen.c	Tue Apr 21 10:11:37 2015 +0200
+++ b/src/ccodegen.c	Sat Apr 25 19:01:16 2015 +0200
@@ -57,6 +57,7 @@
     memset(hltr->word, 0, WORDBUF_SIZE);
     size_t wp = 0, ifp = 0;
     int isstring = 0, iscomment = 0, isinclude = 0, parseinclude = 0;
+    char quote = '\0';
     int isescaping = 0;
 
     if (hltr->iscommentml) {
@@ -126,12 +127,18 @@
         } else {
             /* strings */
             if (!isescaping && (c == '\'' || c == '\"')) {
-                isstring ^= 1;
                 if (isstring) {
-                    memcpy(&(dest[dp]), "<span class=\"c2html-string\">", 28);
-                    dp += 28;
-                    dp = writeescapedchar(dest, dp, c);
+                    if (c == quote) {
+                        isstring = 0;
+                        memcpy(&(dest[dp]), "<span class=\"c2html-string\">", 28);
+                        dp += 28;
+                        dp = writeescapedchar(dest, dp, c);
+                    } else {
+                        dp = writeescapedchar(dest, dp, c);
+                    }
                 } else {
+                    isstring = 1;
+                    quote = c;
                     dp = writeescapedchar(dest, dp, c);
                     memcpy(&(dest[dp]), "</span>", 7);
                     dp += 7;

mercurial