lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 6ffcf2136788b032bdc0f8520b1bbc2a4d2ea76e
parent 6427c61e7c3e6acd467b488c573ac37b0f46d0a2
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Wed, 11 Mar 2009 10:27:08 -0300

ctype 'lalpha' includes '_' (as '_' behaves as a letter from the
point of view of Lua)

Diffstat:
Mlctype.c | 4++--
Mlctype.h | 8+++++---
Mllex.c | 8++++----
3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/lctype.c b/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, diff --git a/lctype.h b/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)) diff --git a/llex.c b/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? */