Sat, 25 Apr 2015 19:01:16 +0200
fixed string highlighting when different quote symbol is in string
src/ccodegen.c | file | annotate | diff | comparison | revisions | |
src/javacodegen.c | file | annotate | diff | comparison | revisions |
--- 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;
--- a/src/javacodegen.c Tue Apr 21 10:11:37 2015 +0200 +++ b/src/javacodegen.c Sat Apr 25 19:01:16 2015 +0200 @@ -59,6 +59,7 @@ memset(hltr->word, 0, WORDBUF_SIZE); size_t wp = 0; int isstring = 0, iscomment = 0, isimport = 0; + char quote = '\0'; int isescaping = 0; if (hltr->iscommentml) { @@ -95,12 +96,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;