cbce581353
CID 173243, 173245: Memory - corruptions (OVERRUN) Added size argument to lcompat_sprintf() to avoid use of INT_MAX CID 173244: Integer handling issues (OVERFLOW_BEFORE_WIDEN) Added cast to uint64_t to avoid a 32 bit overflow warning CID 173242: Integer handling issues (CONSTANT_EXPRESSION_RESULT) Conditionally removed unused luai_numisnan() floating point check CID 173241: Resource leaks (RESOURCE_LEAK) Added missing close(fd) on error path CID 173240: (UNINIT) Fixed uninitialized variable in get_special_prop() CID 147560: Null pointer dereferences (NULL_RETURNS) Cleaned up bad code merge in dsl_dataset_promote_check() CID 28475: Memory - illegal accesses (OVERRUN) Fixed lcompat_sprintf() to use a size paramater CID 28418, 28422: Error handling issues (CHECKED_RETURN) Added function result cast to (void) to avoid warning CID 23935, 28411, 28412: Memory - corruptions (ARRAY_VS_SINGLETON) Added casts to avoid exposing result as an array Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Don Brady <don.brady@delphix.com> Closes #7181
95 lines
1.8 KiB
C
95 lines
1.8 KiB
C
/* BEGIN CSTYLED */
|
|
/*
|
|
** $Id: lctype.h,v 1.12.1.1 2013/04/12 18:48:47 roberto Exp $
|
|
** 'ctype' functions for Lua
|
|
** See Copyright Notice in lua.h
|
|
*/
|
|
|
|
#ifndef lctype_h
|
|
#define lctype_h
|
|
|
|
#include <sys/lua/lua.h>
|
|
|
|
|
|
/*
|
|
** WARNING: the functions defined here do not necessarily correspond
|
|
** to the similar functions in the standard C ctype.h. They are
|
|
** optimized for the specific needs of Lua
|
|
*/
|
|
|
|
#if !defined(LUA_USE_CTYPE)
|
|
|
|
#if 'A' == 65 && '0' == 48
|
|
/* ASCII case: can use its own tables; faster and fixed */
|
|
#define LUA_USE_CTYPE 0
|
|
#else
|
|
/* must use standard C ctype */
|
|
#define LUA_USE_CTYPE 1
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
#if !LUA_USE_CTYPE /* { */
|
|
|
|
#include "llimits.h"
|
|
|
|
|
|
#define ALPHABIT 0
|
|
#define DIGITBIT 1
|
|
#define PRINTBIT 2
|
|
#define SPACEBIT 3
|
|
#define XDIGITBIT 4
|
|
|
|
|
|
#define MASK(B) (1 << (B))
|
|
|
|
|
|
/*
|
|
** add 1 to char to allow index -1 (EOZ)
|
|
*/
|
|
#define testprop(c,p) (luai_ctype_[(lu_byte)(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 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))
|
|
|
|
/*
|
|
** this 'ltolower' only works for alphabetic characters
|
|
*/
|
|
#define ltolower(c) ((c) | ('A' ^ 'a'))
|
|
|
|
|
|
/* two more entries for 0 and -1 (EOZ) */
|
|
LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
|
|
|
|
|
|
#else /* }{ */
|
|
|
|
/*
|
|
** use standard C ctypes
|
|
*/
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
#define lislalpha(c) (isalpha(c) || (c) == '_')
|
|
#define lislalnum(c) (isalnum(c) || (c) == '_')
|
|
#define lisdigit(c) (isdigit(c))
|
|
#define lisspace(c) (isspace(c))
|
|
#define lisprint(c) (isprint(c))
|
|
#define lisxdigit(c) (isxdigit(c))
|
|
|
|
#define ltolower(c) (tolower(c))
|
|
|
|
#endif /* } */
|
|
|
|
#endif
|
|
/* END CSTYLED */
|