aboutsummaryrefslogtreecommitdiff
path: root/lutf8lib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-19 11:15:49 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-19 11:15:49 -0300
commit39bb3cf2422603d854ee12529cc3419dc735802a (patch)
tree656fa40314dab1d612be82210abfed3c4b34d4de /lutf8lib.c
parent9b37a4695ebf50b37b5b4fb279ae948f23b5b6a0 (diff)
downloadlua-39bb3cf2422603d854ee12529cc3419dc735802a.tar.gz
lua-39bb3cf2422603d854ee12529cc3419dc735802a.tar.bz2
lua-39bb3cf2422603d854ee12529cc3419dc735802a.zip
Name 'nonstrict' in the UTF-8 library changed to 'lax'
It is not a good idea to use negative words to describe boolean values. (When we negate that boolean we create a double negative...)
Diffstat (limited to 'lutf8lib.c')
-rw-r--r--lutf8lib.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/lutf8lib.c b/lutf8lib.c
index ec711c9a..16cd68ad 100644
--- a/lutf8lib.c
+++ b/lutf8lib.c
@@ -85,7 +85,7 @@ static const char *utf8_decode (const char *s, utfint *val, int strict) {
85 85
86 86
87/* 87/*
88** utf8len(s [, i [, j [, nonstrict]]]) --> number of characters that 88** utf8len(s [, i [, j [, lax]]]) --> number of characters that
89** start in the range [i,j], or nil + current position if 's' is not 89** start in the range [i,j], or nil + current position if 's' is not
90** well formed in that interval 90** well formed in that interval
91*/ 91*/
@@ -95,13 +95,13 @@ static int utflen (lua_State *L) {
95 const char *s = luaL_checklstring(L, 1, &len); 95 const char *s = luaL_checklstring(L, 1, &len);
96 lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len); 96 lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len);
97 lua_Integer posj = u_posrelat(luaL_optinteger(L, 3, -1), len); 97 lua_Integer posj = u_posrelat(luaL_optinteger(L, 3, -1), len);
98 int nonstrict = lua_toboolean(L, 4); 98 int lax = lua_toboolean(L, 4);
99 luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 2, 99 luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 2,
100 "initial position out of string"); 100 "initial position out of string");
101 luaL_argcheck(L, --posj < (lua_Integer)len, 3, 101 luaL_argcheck(L, --posj < (lua_Integer)len, 3,
102 "final position out of string"); 102 "final position out of string");
103 while (posi <= posj) { 103 while (posi <= posj) {
104 const char *s1 = utf8_decode(s + posi, NULL, !nonstrict); 104 const char *s1 = utf8_decode(s + posi, NULL, !lax);
105 if (s1 == NULL) { /* conversion error? */ 105 if (s1 == NULL) { /* conversion error? */
106 lua_pushnil(L); /* return nil ... */ 106 lua_pushnil(L); /* return nil ... */
107 lua_pushinteger(L, posi + 1); /* ... and current position */ 107 lua_pushinteger(L, posi + 1); /* ... and current position */
@@ -116,7 +116,7 @@ static int utflen (lua_State *L) {
116 116
117 117
118/* 118/*
119** codepoint(s, [i, [j [, nonstrict]]]) -> returns codepoints for all 119** codepoint(s, [i, [j [, lax]]]) -> returns codepoints for all
120** characters that start in the range [i,j] 120** characters that start in the range [i,j]
121*/ 121*/
122static int codepoint (lua_State *L) { 122static int codepoint (lua_State *L) {
@@ -124,7 +124,7 @@ static int codepoint (lua_State *L) {
124 const char *s = luaL_checklstring(L, 1, &len); 124 const char *s = luaL_checklstring(L, 1, &len);
125 lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len); 125 lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len);
126 lua_Integer pose = u_posrelat(luaL_optinteger(L, 3, posi), len); 126 lua_Integer pose = u_posrelat(luaL_optinteger(L, 3, posi), len);
127 int nonstrict = lua_toboolean(L, 4); 127 int lax = lua_toboolean(L, 4);
128 int n; 128 int n;
129 const char *se; 129 const char *se;
130 luaL_argcheck(L, posi >= 1, 2, "out of range"); 130 luaL_argcheck(L, posi >= 1, 2, "out of range");
@@ -138,7 +138,7 @@ static int codepoint (lua_State *L) {
138 se = s + pose; /* string end */ 138 se = s + pose; /* string end */
139 for (s += posi - 1; s < se;) { 139 for (s += posi - 1; s < se;) {
140 utfint code; 140 utfint code;
141 s = utf8_decode(s, &code, !nonstrict); 141 s = utf8_decode(s, &code, !lax);
142 if (s == NULL) 142 if (s == NULL)
143 return luaL_error(L, "invalid UTF-8 code"); 143 return luaL_error(L, "invalid UTF-8 code");
144 lua_pushinteger(L, code); 144 lua_pushinteger(L, code);
@@ -249,15 +249,15 @@ static int iter_auxstrict (lua_State *L) {
249 return iter_aux(L, 1); 249 return iter_aux(L, 1);
250} 250}
251 251
252static int iter_auxnostrict (lua_State *L) { 252static int iter_auxlax (lua_State *L) {
253 return iter_aux(L, 0); 253 return iter_aux(L, 0);
254} 254}
255 255
256 256
257static int iter_codes (lua_State *L) { 257static int iter_codes (lua_State *L) {
258 int nonstrict = lua_toboolean(L, 2); 258 int lax = lua_toboolean(L, 2);
259 luaL_checkstring(L, 1); 259 luaL_checkstring(L, 1);
260 lua_pushcfunction(L, nonstrict ? iter_auxnostrict : iter_auxstrict); 260 lua_pushcfunction(L, lax ? iter_auxlax : iter_auxstrict);
261 lua_pushvalue(L, 1); 261 lua_pushvalue(L, 1);
262 lua_pushinteger(L, 0); 262 lua_pushinteger(L, 0);
263 return 3; 263 return 3;