mirror of
https://github.com/lua/lua
synced 2024-11-27 07:09:36 +03:00
139d562861
operations)
51 lines
1.0 KiB
C
51 lines
1.0 KiB
C
/*
|
|
** $Id: lctype.h,v 1.6 2009/05/18 17:15:14 roberto Exp roberto $
|
|
** 'ctype' functions for Lua
|
|
** See Copyright Notice in lua.h
|
|
*/
|
|
|
|
#ifndef lctype_h
|
|
#define lctype_h
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
#include "lua.h"
|
|
|
|
#include "llimits.h"
|
|
|
|
|
|
#define ALPHABIT 0
|
|
#define DIGITBIT 1
|
|
#define PRINTBIT 2
|
|
#define SPACEBIT 3
|
|
#define XDIGITBIT 4
|
|
#define UPPERBIT 5
|
|
|
|
|
|
#define MASK(B) (1 << (B))
|
|
|
|
|
|
/*
|
|
** add 1 to char to allow index -1 (EOZ)
|
|
*/
|
|
#define testprop(c,p) (luai_ctype_[(c)+1] & (p))
|
|
|
|
/*
|
|
** '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 lisupper(c) testprop(c, MASK(UPPERBIT))
|
|
#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 lu_byte luai_ctype_[UCHAR_MAX + 2];
|
|
|
|
#endif
|
|
|