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 |
1.1 --- a/src/ccodegen.c Tue Apr 21 10:11:37 2015 +0200 1.2 +++ b/src/ccodegen.c Sat Apr 25 19:01:16 2015 +0200 1.3 @@ -57,6 +57,7 @@ 1.4 memset(hltr->word, 0, WORDBUF_SIZE); 1.5 size_t wp = 0, ifp = 0; 1.6 int isstring = 0, iscomment = 0, isinclude = 0, parseinclude = 0; 1.7 + char quote = '\0'; 1.8 int isescaping = 0; 1.9 1.10 if (hltr->iscommentml) { 1.11 @@ -126,12 +127,18 @@ 1.12 } else { 1.13 /* strings */ 1.14 if (!isescaping && (c == '\'' || c == '\"')) { 1.15 - isstring ^= 1; 1.16 if (isstring) { 1.17 - memcpy(&(dest[dp]), "<span class=\"c2html-string\">", 28); 1.18 - dp += 28; 1.19 - dp = writeescapedchar(dest, dp, c); 1.20 + if (c == quote) { 1.21 + isstring = 0; 1.22 + memcpy(&(dest[dp]), "<span class=\"c2html-string\">", 28); 1.23 + dp += 28; 1.24 + dp = writeescapedchar(dest, dp, c); 1.25 + } else { 1.26 + dp = writeescapedchar(dest, dp, c); 1.27 + } 1.28 } else { 1.29 + isstring = 1; 1.30 + quote = c; 1.31 dp = writeescapedchar(dest, dp, c); 1.32 memcpy(&(dest[dp]), "</span>", 7); 1.33 dp += 7;
2.1 --- a/src/javacodegen.c Tue Apr 21 10:11:37 2015 +0200 2.2 +++ b/src/javacodegen.c Sat Apr 25 19:01:16 2015 +0200 2.3 @@ -59,6 +59,7 @@ 2.4 memset(hltr->word, 0, WORDBUF_SIZE); 2.5 size_t wp = 0; 2.6 int isstring = 0, iscomment = 0, isimport = 0; 2.7 + char quote = '\0'; 2.8 int isescaping = 0; 2.9 2.10 if (hltr->iscommentml) { 2.11 @@ -95,12 +96,18 @@ 2.12 } else { 2.13 /* strings */ 2.14 if (!isescaping && (c == '\'' || c == '\"')) { 2.15 - isstring ^= 1; 2.16 if (isstring) { 2.17 - memcpy(&(dest[dp]), "<span class=\"c2html-string\">", 28); 2.18 - dp += 28; 2.19 - dp = writeescapedchar(dest, dp, c); 2.20 + if (c == quote) { 2.21 + isstring = 0; 2.22 + memcpy(&(dest[dp]), "<span class=\"c2html-string\">", 28); 2.23 + dp += 28; 2.24 + dp = writeescapedchar(dest, dp, c); 2.25 + } else { 2.26 + dp = writeescapedchar(dest, dp, c); 2.27 + } 2.28 } else { 2.29 + isstring = 1; 2.30 + quote = c; 2.31 dp = writeescapedchar(dest, dp, c); 2.32 memcpy(&(dest[dp]), "</span>", 7); 2.33 dp += 7;