exempted glsl color syntax from string contents

This commit is contained in:
Jarcode
2018-02-07 19:53:23 -08:00
parent aea30abf67
commit ec6d4d0c37

View File

@@ -275,7 +275,8 @@ void ext_process(struct glsl_ext* ext, const char* f) {
char** args = NULL; char** args = NULL;
size_t args_sz = 0; size_t args_sz = 0;
bool prev_slash = false, comment = false, comment_line = false, prev_asterix = false; bool prev_slash = false, comment = false, comment_line = false, prev_asterix = false,
prev_escape = false, string = false;
for (t = 0; t <= source_len; ++t) { for (t = 0; t <= source_len; ++t) {
at = source_len == t ? '\0' : ext->source[t]; at = source_len == t ? '\0' : ext->source[t];
@@ -304,6 +305,17 @@ void ext_process(struct glsl_ext* ext, const char* f) {
case GLSL: /* copying GLSL source or unrelated preprocessor syntax */ case GLSL: /* copying GLSL source or unrelated preprocessor syntax */
{ {
switch (at) { switch (at) {
case '"':
if (!comment && !prev_escape)
string = !string;
goto normal_char;
case '\\':
if (!comment) {
prev_escape = !prev_escape;
prev_asterix = false;
prev_slash = false;
goto copy;
} else goto normal_char;
case '/': case '/':
if (!comment) { if (!comment) {
if (prev_slash) { if (prev_slash) {
@@ -317,6 +329,7 @@ void ext_process(struct glsl_ext* ext, const char* f) {
prev_asterix = false; prev_asterix = false;
} }
} }
prev_escape = false;
goto copy; goto copy;
case '*': case '*':
if (!comment) { if (!comment) {
@@ -325,10 +338,11 @@ void ext_process(struct glsl_ext* ext, const char* f) {
prev_slash = false; prev_slash = false;
} }
} else prev_asterix = true; } else prev_asterix = true;
prev_escape = false;
goto copy; goto copy;
case '#': { case '#': {
/* handle hex color syntax */ /* handle hex color syntax */
if (!comment) { if (!comment && !string) {
state = COLOR; state = COLOR;
cbuf_idx = 0; cbuf_idx = 0;
continue; continue;
@@ -344,6 +358,7 @@ void ext_process(struct glsl_ext* ext, const char* f) {
default: default:
prev_asterix = false; prev_asterix = false;
prev_slash = false; prev_slash = false;
prev_escape = false;
goto copy; goto copy;
} }
} }