From 3f880ecb67f2a727cf854f02361482a8f53d8189 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Tue, 6 Jun 2017 12:54:19 -0700 Subject: [PATCH] Fix pointer, pointer constructs and quoted string scan_rewind --- Platform/Apple/tools/PLASMA/src/lex.c | 11 +++++++---- Platform/Apple/tools/PLASMA/src/parse.c | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Platform/Apple/tools/PLASMA/src/lex.c b/Platform/Apple/tools/PLASMA/src/lex.c index 8c72b0c5..cded50d7 100644 --- a/Platform/Apple/tools/PLASMA/src/lex.c +++ b/Platform/Apple/tools/PLASMA/src/lex.c @@ -234,16 +234,18 @@ t_token scan(void) scanpos += 4; } } - else if (scanpos[0] == '\"') + else if ((scanpos[0] & 0x7F) == '\"') // Hack for string quote char in case we have to rewind later { - char *scanshift; + char *scanshift, quotechar; int scanoffset; /* * String constant. */ + quotechar = scanpos[0]; + *scanpos |= 0x80; // Set high bit in case of rewind scantoken = STRING_TOKEN; constval = (long)++scanpos; - while (*scanpos && *scanpos != '\"') + while (*scanpos && *scanpos != quotechar) { if (*scanpos == '\\') { @@ -288,11 +290,12 @@ t_token scan(void) } scanpos++; } - if (!*scanpos++) + if (!*scanpos) { parse_error("Unterminated string"); return (-1); } + *scanpos++ |= 0x80; // Set high bit in case of rewind } else { diff --git a/Platform/Apple/tools/PLASMA/src/parse.c b/Platform/Apple/tools/PLASMA/src/parse.c index dca1e976..8cd604de 100644 --- a/Platform/Apple/tools/PLASMA/src/parse.c +++ b/Platform/Apple/tools/PLASMA/src/parse.c @@ -510,7 +510,7 @@ t_opseq *parse_value(t_opseq *codeseq, int rvalue, int *stackdepth) if (stackdepth) *stackdepth = cfnvals; cfnvals = 1; - type &= ~FUNC_TYPE; + type &= ~(FUNC_TYPE | VAR_TYPE); } else if (scantoken == OPEN_BRACKET_TOKEN) { @@ -565,7 +565,7 @@ t_opseq *parse_value(t_opseq *codeseq, int rvalue, int *stackdepth) *stackdepth = cfnvals; type &= ~FUNC_TYPE; } - else if (type & VAR_TYPE) + else if (type & (VAR_TYPE | PTR_TYPE)) { /* * Pointer dereference