From 452deea23dffc0dd3714f3817ab47058d8d8cb30 Mon Sep 17 00:00:00 2001 From: Jarcode Date: Tue, 2 Apr 2019 15:45:20 -0700 Subject: [PATCH] Handle preceding operators for pipe defaults --- glsl_ext.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/glsl_ext.c b/glsl_ext.c index 5a5d3b9..5431cc2 100644 --- a/glsl_ext.c +++ b/glsl_ext.c @@ -330,7 +330,7 @@ void ext_process(struct glsl_ext* ext, const char* f) { int state = LINE_START; size_t macro_start_idx, arg_start_idx, cbuf_idx, bbuf_idx; size_t line = 1; - bool quoted = false, arg_start, b_sep = false, b_spc = false; + bool quoted = false, arg_start, b_sep = false, b_spc = false, b_pre = true; int b_br = 0; char cbuf[9]; char bbuf[256]; @@ -417,6 +417,7 @@ void ext_process(struct glsl_ext* ext, const char* f) { state = BIND; b_sep = false; b_spc = false; + b_pre = true; b_br = 0; bbuf_idx = 0; continue; @@ -480,9 +481,11 @@ void ext_process(struct glsl_ext* ext, const char* f) { else goto handle_bind; /* continue reading if nested */ } case ' ': if (b_br <= 0) b_spc = true; /* flag a non-braced space */ - case '#': - if (b_sep) goto handle_bind; /* handle color syntax only for defaults */ - else goto emit_bind; /* if '#' is encountered, skip to emit */ + case '#': case '+': case '-': + case '!': case '~': case '&': + if (b_sep && (b_br > 0 || b_pre)) + goto handle_bind; /* handle precede syntax only for defaults */ + else goto emit_bind; /* if encountered, skip to emit */ case ':': b_sep = true; handle_bind: /* use character for binding syntax */ case 'a' ... 'z': @@ -491,6 +494,8 @@ void ext_process(struct glsl_ext* ext, const char* f) { case '_': { if (b_spc && b_br <= 0) goto emit_bind; /* skip non-braced characters after space: `@sym:vec4 c` */ + if (b_sep && at != ':') + b_pre = false; bbuf[bbuf_idx] = at; ++bbuf_idx; if (bbuf_idx >= sizeof(bbuf) - 1)