mirror of
https://github.com/lua/lua
synced 2025-03-09 23:41:42 +03:00
small bug: EOZ is a valid character to be tested
This commit is contained in:
parent
3dbf305408
commit
b1e1c15ced
5
lctype.c
5
lctype.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lctype.c,v 1.3 2009/03/10 17:42:33 roberto Exp roberto $
|
||||
** $Id: lctype.c,v 1.4 2009/03/11 13:27:32 roberto Exp roberto $
|
||||
** 'ctype' functions for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -8,7 +8,8 @@
|
||||
|
||||
#include "lctype.h"
|
||||
|
||||
const char luai_ctype_[UCHAR_MAX + 1] = {
|
||||
const char luai_ctype_[UCHAR_MAX + 2] = {
|
||||
0x00, /* EOZ */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
28
lctype.h
28
lctype.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lctype.h,v 1.3 2009/03/10 17:42:33 roberto Exp roberto $
|
||||
** $Id: lctype.h,v 1.4 2009/03/11 13:27:32 roberto Exp roberto $
|
||||
** 'ctype' functions for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -23,16 +23,24 @@
|
||||
#define MASK(B) (1 << (B))
|
||||
|
||||
|
||||
/* '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))
|
||||
#define lisxdigit(x) (luai_ctype_[x] & MASK(XDIGITBIT))
|
||||
/*
|
||||
** add 1 to char to allow index -1 (EOZ)
|
||||
*/
|
||||
#define testprop(c,p) (luai_ctype_[(c)+1] & (p))
|
||||
|
||||
LUAI_DATA const char luai_ctype_[UCHAR_MAX + 1];
|
||||
/*
|
||||
** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
|
||||
*/
|
||||
#define lislalpha(c) testprop(c, MASK(ALPHABIT))
|
||||
#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
|
||||
#define lisdigit(c) testprop(c, MASK(DIGITBIT))
|
||||
#define lisspace(c) testprop(c, MASK(SPACEBIT))
|
||||
#define lisprint(c) testprop(c, MASK(PRINTBIT))
|
||||
#define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
|
||||
|
||||
|
||||
/* one more entry for 0 and one more for -1 (EOZ) */
|
||||
LUAI_DATA const char luai_ctype_[UCHAR_MAX + 2];
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user