aboutsummaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--llex.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/llex.c b/llex.c
index 4b5a1f75..f8bb3ea4 100644
--- a/llex.c
+++ b/llex.c
@@ -44,7 +44,7 @@
44/* ORDER RESERVED */ 44/* ORDER RESERVED */
45static const char *const luaX_tokens [] = { 45static const char *const luaX_tokens [] = {
46 "and", "break", "do", "else", "elseif", 46 "and", "break", "do", "else", "elseif",
47 "end", "false", "for", "function", "goto", "if", 47 "end", "false", "for", "function", "global", "goto", "if",
48 "in", "local", "nil", "not", "or", "repeat", 48 "in", "local", "nil", "not", "or", "repeat",
49 "return", "then", "true", "until", "while", 49 "return", "then", "true", "until", "while",
50 "//", "..", "...", "==", ">=", "<=", "~=", 50 "//", "..", "...", "==", ">=", "<=", "~=",
@@ -184,7 +184,15 @@ void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source,
184 ls->linenumber = 1; 184 ls->linenumber = 1;
185 ls->lastline = 1; 185 ls->lastline = 1;
186 ls->source = source; 186 ls->source = source;
187 ls->envn = luaS_newliteral(L, LUA_ENV); /* get env name */ 187 /* all three strings here ("_ENV", "break", "global") were fixed,
188 so they cannot be collected */
189 ls->envn = luaS_newliteral(L, LUA_ENV); /* get env string */
190 ls->brkn = luaS_newliteral(L, "break"); /* get "break" string */
191#if defined(LUA_COMPAT_GLOBAL)
192 /* compatibility mode: "global" is not a reserved word */
193 ls->glbn = luaS_newliteral(L, "global"); /* get "global" string */
194 ls->glbn->extra = 0; /* mark it as not reserved */
195#endif
188 luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ 196 luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */
189} 197}
190 198
@@ -354,12 +362,12 @@ static int readhexaesc (LexState *ls) {
354** for error reporting in case of errors; 'i' counts the number of 362** for error reporting in case of errors; 'i' counts the number of
355** saved characters, so that they can be removed if case of success. 363** saved characters, so that they can be removed if case of success.
356*/ 364*/
357static unsigned long readutf8esc (LexState *ls) { 365static l_uint32 readutf8esc (LexState *ls) {
358 unsigned long r; 366 l_uint32 r;
359 int i = 4; /* number of chars to be removed: start with #"\u{X" */ 367 int i = 4; /* number of chars to be removed: start with #"\u{X" */
360 save_and_next(ls); /* skip 'u' */ 368 save_and_next(ls); /* skip 'u' */
361 esccheck(ls, ls->current == '{', "missing '{'"); 369 esccheck(ls, ls->current == '{', "missing '{'");
362 r = cast_ulong(gethexa(ls)); /* must have at least one digit */ 370 r = cast_uint(gethexa(ls)); /* must have at least one digit */
363 while (cast_void(save_and_next(ls)), lisxdigit(ls->current)) { 371 while (cast_void(save_and_next(ls)), lisxdigit(ls->current)) {
364 i++; 372 i++;
365 esccheck(ls, r <= (0x7FFFFFFFu >> 4), "UTF-8 value too large"); 373 esccheck(ls, r <= (0x7FFFFFFFu >> 4), "UTF-8 value too large");