mirror of
https://github.com/lua/lua.git
synced 2025-01-28 06:03:00 +08:00
ctype 'lalpha' includes '_' (as '_' behaves as a letter from the
point of view of Lua)
This commit is contained in:
parent
6427c61e7c
commit
6ffcf21367
4
lctype.c
4
lctype.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lctype.c,v 1.2 2009/02/20 13:11:15 roberto Exp roberto $
|
||||
** $Id: lctype.c,v 1.3 2009/03/10 17:42:33 roberto Exp roberto $
|
||||
** 'ctype' functions for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -20,7 +20,7 @@ const char luai_ctype_[UCHAR_MAX + 1] = {
|
||||
0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||
0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05,
|
||||
0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
|
8
lctype.h
8
lctype.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lctype.h,v 1.2 2009/02/20 13:11:15 roberto Exp roberto $
|
||||
** $Id: lctype.h,v 1.3 2009/03/10 17:42:33 roberto Exp roberto $
|
||||
** 'ctype' functions for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -23,8 +23,10 @@
|
||||
#define MASK(B) (1 << (B))
|
||||
|
||||
|
||||
#define lisalpha(x) (luai_ctype_[x] & MASK(ALPHABIT))
|
||||
#define lisalnum(x) (luai_ctype_[x] & (MASK(ALPHABIT) | MASK(DIGITBIT)))
|
||||
/* 'lalpha' (Lua alphabetic) includes '_' */
|
||||
#define lislalpha(x) (luai_ctype_[x] & MASK(ALPHABIT))
|
||||
/* ditto */
|
||||
#define lislalnum(x) (luai_ctype_[x] & (MASK(ALPHABIT) | MASK(DIGITBIT)))
|
||||
#define lisdigit(x) (luai_ctype_[x] & MASK(DIGITBIT))
|
||||
#define lisspace(x) (luai_ctype_[x] & MASK(SPACEBIT))
|
||||
#define lisprint(x) (luai_ctype_[x] & MASK(PRINTBIT))
|
||||
|
8
llex.c
8
llex.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: llex.c,v 2.30 2009/02/11 18:25:20 roberto Exp roberto $
|
||||
** $Id: llex.c,v 2.31 2009/02/19 17:18:25 roberto Exp roberto $
|
||||
** Lexical Analyzer
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -206,7 +206,7 @@ static void read_numeral (LexState *ls, SemInfo *seminfo) {
|
||||
} while (lisdigit(ls->current) || ls->current == '.');
|
||||
if (check_next(ls, "Ee")) /* `E'? */
|
||||
check_next(ls, "+-"); /* optional exponent sign */
|
||||
while (lisalnum(ls->current) || ls->current == '_')
|
||||
while (lislalnum(ls->current))
|
||||
save_and_next(ls);
|
||||
save(ls, '\0');
|
||||
buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
|
||||
@ -408,12 +408,12 @@ static int llex (LexState *ls, SemInfo *seminfo) {
|
||||
read_numeral(ls, seminfo);
|
||||
return TK_NUMBER;
|
||||
}
|
||||
else if (lisalpha(ls->current) || ls->current == '_') {
|
||||
else if (lislalpha(ls->current)) {
|
||||
/* identifier or reserved word */
|
||||
TString *ts;
|
||||
do {
|
||||
save_and_next(ls);
|
||||
} while (lisalnum(ls->current) || ls->current == '_');
|
||||
} while (lislalnum(ls->current));
|
||||
ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
|
||||
luaZ_bufflen(ls->buff));
|
||||
if (ts->tsv.reserved > 0) /* reserved word? */
|
||||
|
Loading…
x
Reference in New Issue
Block a user