diff options
Diffstat (limited to '')
-rw-r--r-- | src/lj_lex.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lj_lex.c b/src/lj_lex.c index ada0876e..61c7ff43 100644 --- a/src/lj_lex.c +++ b/src/lj_lex.c | |||
@@ -82,7 +82,7 @@ static LJ_AINLINE LexChar lex_savenext(LexState *ls) | |||
82 | static void lex_newline(LexState *ls) | 82 | static void lex_newline(LexState *ls) |
83 | { | 83 | { |
84 | LexChar old = ls->c; | 84 | LexChar old = ls->c; |
85 | lua_assert(lex_iseol(ls)); | 85 | lj_assertLS(lex_iseol(ls), "bad usage"); |
86 | lex_next(ls); /* Skip "\n" or "\r". */ | 86 | lex_next(ls); /* Skip "\n" or "\r". */ |
87 | if (lex_iseol(ls) && ls->c != old) lex_next(ls); /* Skip "\n\r" or "\r\n". */ | 87 | if (lex_iseol(ls) && ls->c != old) lex_next(ls); /* Skip "\n\r" or "\r\n". */ |
88 | if (++ls->linenumber >= LJ_MAX_LINE) | 88 | if (++ls->linenumber >= LJ_MAX_LINE) |
@@ -96,7 +96,7 @@ static void lex_number(LexState *ls, TValue *tv) | |||
96 | { | 96 | { |
97 | StrScanFmt fmt; | 97 | StrScanFmt fmt; |
98 | LexChar c, xp = 'e'; | 98 | LexChar c, xp = 'e'; |
99 | lua_assert(lj_char_isdigit(ls->c)); | 99 | lj_assertLS(lj_char_isdigit(ls->c), "bad usage"); |
100 | if ((c = ls->c) == '0' && (lex_savenext(ls) | 0x20) == 'x') | 100 | if ((c = ls->c) == '0' && (lex_savenext(ls) | 0x20) == 'x') |
101 | xp = 'p'; | 101 | xp = 'p'; |
102 | while (lj_char_isident(ls->c) || ls->c == '.' || | 102 | while (lj_char_isident(ls->c) || ls->c == '.' || |
@@ -116,7 +116,8 @@ static void lex_number(LexState *ls, TValue *tv) | |||
116 | } else if (fmt != STRSCAN_ERROR) { | 116 | } else if (fmt != STRSCAN_ERROR) { |
117 | lua_State *L = ls->L; | 117 | lua_State *L = ls->L; |
118 | GCcdata *cd; | 118 | GCcdata *cd; |
119 | lua_assert(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG); | 119 | lj_assertLS(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG, |
120 | "unexpected number format %d", fmt); | ||
120 | if (!ctype_ctsG(G(L))) { | 121 | if (!ctype_ctsG(G(L))) { |
121 | ptrdiff_t oldtop = savestack(L, L->top); | 122 | ptrdiff_t oldtop = savestack(L, L->top); |
122 | luaopen_ffi(L); /* Load FFI library on-demand. */ | 123 | luaopen_ffi(L); /* Load FFI library on-demand. */ |
@@ -133,7 +134,8 @@ static void lex_number(LexState *ls, TValue *tv) | |||
133 | lj_parse_keepcdata(ls, tv, cd); | 134 | lj_parse_keepcdata(ls, tv, cd); |
134 | #endif | 135 | #endif |
135 | } else { | 136 | } else { |
136 | lua_assert(fmt == STRSCAN_ERROR); | 137 | lj_assertLS(fmt == STRSCAN_ERROR, |
138 | "unexpected number format %d", fmt); | ||
137 | lj_lex_error(ls, TK_number, LJ_ERR_XNUMBER); | 139 | lj_lex_error(ls, TK_number, LJ_ERR_XNUMBER); |
138 | } | 140 | } |
139 | } | 141 | } |
@@ -143,7 +145,7 @@ static int lex_skipeq(LexState *ls) | |||
143 | { | 145 | { |
144 | int count = 0; | 146 | int count = 0; |
145 | LexChar s = ls->c; | 147 | LexChar s = ls->c; |
146 | lua_assert(s == '[' || s == ']'); | 148 | lj_assertLS(s == '[' || s == ']', "bad usage"); |
147 | while (lex_savenext(ls) == '=' && count < 0x20000000) | 149 | while (lex_savenext(ls) == '=' && count < 0x20000000) |
148 | count++; | 150 | count++; |
149 | return (ls->c == s) ? count : (-count) - 1; | 151 | return (ls->c == s) ? count : (-count) - 1; |
@@ -469,7 +471,7 @@ void lj_lex_next(LexState *ls) | |||
469 | /* Look ahead for the next token. */ | 471 | /* Look ahead for the next token. */ |
470 | LexToken lj_lex_lookahead(LexState *ls) | 472 | LexToken lj_lex_lookahead(LexState *ls) |
471 | { | 473 | { |
472 | lua_assert(ls->lookahead == TK_eof); | 474 | lj_assertLS(ls->lookahead == TK_eof, "double lookahead"); |
473 | ls->lookahead = lex_scan(ls, &ls->lookaheadval); | 475 | ls->lookahead = lex_scan(ls, &ls->lookaheadval); |
474 | return ls->lookahead; | 476 | return ls->lookahead; |
475 | } | 477 | } |