From da033b6301afd026d2d914272678106f0e3d1593 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Sat, 18 Mar 2017 21:10:05 -0400 Subject: [PATCH] why --- scanner.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/scanner.c b/scanner.c index a194b23..697e7bb 100755 --- a/scanner.c +++ b/scanner.c @@ -88,10 +88,10 @@ Token malar_next_token(Buffer * sc_buf) /*DECLARE YOUR VARIABLES HERE IF NEEDED */ /* Counter for loops in string error case */ int i; - /*String offset for the str_LTBL*/ static short str_offset = 0; + if (sc_buf == NULL) { scerrnum = 1; return aa_table[ES]("RUN TIME ERROR: "); /* WHOOPS */ @@ -165,7 +165,7 @@ Token malar_next_token(Buffer * sc_buf) else { /* Bad character, pump out an error token */ t.code = ERR_T; b_retract(sc_buf); - b_retract(sc_buf); + b_retract(sc_buf); /* Retract twice to re-read '!' */ t.attribute.err_lex[0] = c = b_getc(sc_buf); t.attribute.err_lex[1] = c = b_getc(sc_buf); t.attribute.err_lex[2] = '\0'; @@ -194,18 +194,18 @@ Token malar_next_token(Buffer * sc_buf) for (; c != '\"'; c = b_getc(sc_buf), ++lexend) { if (c == '\n' || c == '\r') ++line; - if (c == '\0' || b_eob(sc_buf)) { /* Illegal string, make it an error token */ + if (c == '\0' || b_eob(sc_buf) || c == 255) { /* Illegal string, make it an error token */ b_retract_to_mark(sc_buf); b_retract(sc_buf); - b_retract(sc_buf); t.code = ERR_T; - for (i = 0; i < lexend; ++i) { + c = b_getc(sc_buf); + for (i = 0; i < (lexend - lexstart); c = b_getc(sc_buf), ++i) { /* Continue until the end of the lexeme where error was found * (error string attribute full) */ - if (i == ERR_LEN) continue; - if (i < (ERR_LEN - 3)) - t.attribute.err_lex[i] = b_getc(sc_buf); + if (i < (ERR_LEN - 3)) { + t.attribute.err_lex[i] = c; + } else { t.attribute.err_lex[i] = '.'; } @@ -216,7 +216,6 @@ Token malar_next_token(Buffer * sc_buf) } /* end for loop, string finished and considered valid */ b_retract_to_mark(sc_buf); - /* Copy the matched string literal to str_LTBL */ t.attribute.str_offset = str_offset; c = b_getc(sc_buf); @@ -241,7 +240,6 @@ Token malar_next_token(Buffer * sc_buf) if (accept != NOAS) { break; } - /*c = b_getc(sc_buf);*/ } /*