diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-05-27 11:46:47 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-05-27 11:46:47 -0300 |
commit | aa8d4a782d88738b3ea921cde5a450656da8fa63 (patch) | |
tree | ecdc874d2476a40ad3857d2c03aaced9d0e04598 /lutf8lib.c | |
parent | efcf24be0c22cba57b298161bf4ab0561fd3c08e (diff) | |
download | lua-aa8d4a782d88738b3ea921cde5a450656da8fa63.tar.gz lua-aa8d4a782d88738b3ea921cde5a450656da8fa63.tar.bz2 lua-aa8d4a782d88738b3ea921cde5a450656da8fa63.zip |
Details (more uniformity in error messages)
Diffstat (limited to 'lutf8lib.c')
-rw-r--r-- | lutf8lib.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -97,9 +97,9 @@ static int utflen (lua_State *L) { | |||
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 lax = 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 bounds"); |
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 bounds"); |
103 | while (posi <= posj) { | 103 | while (posi <= posj) { |
104 | const char *s1 = utf8_decode(s + posi, NULL, !lax); | 104 | const char *s1 = utf8_decode(s + posi, NULL, !lax); |
105 | if (s1 == NULL) { /* conversion error? */ | 105 | if (s1 == NULL) { /* conversion error? */ |
@@ -127,8 +127,8 @@ static int codepoint (lua_State *L) { | |||
127 | int lax = 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 bounds"); |
131 | luaL_argcheck(L, pose <= (lua_Integer)len, 3, "out of range"); | 131 | luaL_argcheck(L, pose <= (lua_Integer)len, 3, "out of bounds"); |
132 | if (posi > pose) return 0; /* empty interval; return no values */ | 132 | if (posi > pose) return 0; /* empty interval; return no values */ |
133 | if (pose - posi >= INT_MAX) /* (lua_Integer -> int) overflow? */ | 133 | if (pose - posi >= INT_MAX) /* (lua_Integer -> int) overflow? */ |
134 | return luaL_error(L, "string slice too long"); | 134 | return luaL_error(L, "string slice too long"); |
@@ -187,7 +187,7 @@ static int byteoffset (lua_State *L) { | |||
187 | lua_Integer posi = (n >= 0) ? 1 : len + 1; | 187 | lua_Integer posi = (n >= 0) ? 1 : len + 1; |
188 | posi = u_posrelat(luaL_optinteger(L, 3, posi), len); | 188 | posi = u_posrelat(luaL_optinteger(L, 3, posi), len); |
189 | luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 3, | 189 | luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 3, |
190 | "position out of range"); | 190 | "position out of bounds"); |
191 | if (n == 0) { | 191 | if (n == 0) { |
192 | /* find beginning of current byte sequence */ | 192 | /* find beginning of current byte sequence */ |
193 | while (posi > 0 && iscont(s + posi)) posi--; | 193 | while (posi > 0 && iscont(s + posi)) posi--; |