File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 13
13
/*
14
14
** WARNING: the functions defined here do not necessarily correspond
15
15
** to the similar functions in the standard C ctype.h. They are
16
- ** optimized for the specific needs of Lua
16
+ ** optimized for the specific needs of Lua.
17
17
*/
18
18
19
19
#if !defined(LUA_USE_CTYPE )
61
61
#define lisprint (c ) testprop(c, MASK(PRINTBIT))
62
62
#define lisxdigit (c ) testprop(c, MASK(XDIGITBIT))
63
63
64
+
64
65
/*
65
- ** this 'ltolower' only works for alphabetic characters
66
+ ** In ASCII, this 'ltolower' is correct for alphabetic characters and
67
+ ** for '.'. That is enough for Lua needs. ('check_exp' ensures that
68
+ ** the character either is an upper-case letter or is unchanged by
69
+ ** the transformation, which holds for lower-case letters and '.'.)
66
70
*/
67
- #define ltolower (c ) ((c) | ('A' ^ 'a'))
71
+ #define ltolower (c ) \
72
+ check_exp(('A' <= (c) && (c) <= 'Z') || (c) == ((c) | ('A' ^ 'a')), \
73
+ (c) | ('A' ^ 'a'))
68
74
69
75
70
- /* two more entries for 0 and -1 (EOZ) */
76
+ /* one entry for each character and for -1 (EOZ) */
71
77
LUAI_DDEC (const lu_byte luai_ctype_ [UCHAR_MAX + 2 ];)
72
78
73
79
You can’t perform that action at this time.
0 commit comments