aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-09-03 09:52:43 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-09-03 09:52:43 -0300
commit8496112a18c887449d37e5aadbb6daec34ae54c0 (patch)
tree00558700e03f0105c16939a0f17d93320983d283
parent6bc0f13505bf5d4f613d725fe008c79e72f83ddf (diff)
downloadlua-8496112a18c887449d37e5aadbb6daec34ae54c0.tar.gz
lua-8496112a18c887449d37e5aadbb6daec34ae54c0.tar.bz2
lua-8496112a18c887449d37e5aadbb6daec34ae54c0.zip
Better documentation for 'lctype.h'
The old documentation said that 'ltolower' only works for alphabetic characters. However, 'l_str2d' uses it (correctly) also on dots ('.').
-rw-r--r--lctype.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/lctype.h b/lctype.h
index cbff4d7e..864e1901 100644
--- a/lctype.h
+++ b/lctype.h
@@ -13,7 +13,7 @@
13/* 13/*
14** WARNING: the functions defined here do not necessarily correspond 14** WARNING: the functions defined here do not necessarily correspond
15** to the similar functions in the standard C ctype.h. They are 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#if !defined(LUA_USE_CTYPE) 19#if !defined(LUA_USE_CTYPE)
@@ -61,13 +61,19 @@
61#define lisprint(c) testprop(c, MASK(PRINTBIT)) 61#define lisprint(c) testprop(c, MASK(PRINTBIT))
62#define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 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) */
71LUAI_DDEC(const lu_byte luai_ctype_[UCHAR_MAX + 2];) 77LUAI_DDEC(const lu_byte luai_ctype_[UCHAR_MAX + 2];)
72 78
73 79