aboutsummaryrefslogtreecommitdiff
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
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...)
-rw-r--r--lutf8lib.c18
-rw-r--r--manual/manual.of8
2 files changed, 13 insertions, 13 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;
diff --git a/manual/manual.of b/manual/manual.of
index b7ced443..fc2550e0 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -7315,7 +7315,7 @@ valid sequences (well formed and not overlong).
7315By default, they only accept byte sequences 7315By default, they only accept byte sequences
7316that result in valid Unicode code points, 7316that result in valid Unicode code points,
7317rejecting values greater than @T{10FFFF} and surrogates. 7317rejecting values greater than @T{10FFFF} and surrogates.
7318A boolean argument @id{nonstrict}, when available, 7318A boolean argument @id{lax}, when available,
7319lifts these checks, 7319lifts these checks,
7320so that all values up to @T{0x7FFFFFFF} are accepted. 7320so that all values up to @T{0x7FFFFFFF} are accepted.
7321(Not well formed and overlong sequences are still rejected.) 7321(Not well formed and overlong sequences are still rejected.)
@@ -7338,7 +7338,7 @@ assuming that the subject is a valid UTF-8 string.
7338 7338
7339} 7339}
7340 7340
7341@LibEntry{utf8.codes (s [, nonstrict])| 7341@LibEntry{utf8.codes (s [, lax])|
7342 7342
7343Returns values so that the construction 7343Returns values so that the construction
7344@verbatim{ 7344@verbatim{
@@ -7351,7 +7351,7 @@ It raises an error if it meets any invalid byte sequence.
7351 7351
7352} 7352}
7353 7353
7354@LibEntry{utf8.codepoint (s [, i [, j [, nonstrict]]])| 7354@LibEntry{utf8.codepoint (s [, i [, j [, lax]]])|
7355 7355
7356Returns the codepoints (as integers) from all characters in @id{s} 7356Returns the codepoints (as integers) from all characters in @id{s}
7357that start between byte position @id{i} and @id{j} (both included). 7357that start between byte position @id{i} and @id{j} (both included).
@@ -7360,7 +7360,7 @@ It raises an error if it meets any invalid byte sequence.
7360 7360
7361} 7361}
7362 7362
7363@LibEntry{utf8.len (s [, i [, j [, nonstrict]]])| 7363@LibEntry{utf8.len (s [, i [, j [, lax]]])|
7364 7364
7365Returns the number of UTF-8 characters in string @id{s} 7365Returns the number of UTF-8 characters in string @id{s}
7366that start between positions @id{i} and @id{j} (both inclusive). 7366that start between positions @id{i} and @id{j} (both inclusive).