aboutsummaryrefslogtreecommitdiff
path: root/lutf8lib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-08-16 14:58:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-08-16 14:58:02 -0300
commitb96b0b5abbf40cbdbed7952bf35a5a27ddf75928 (patch)
tree5d9d5463cb7d3424833abab20dd87bce1f4b240f /lutf8lib.c
parentca13be9af784b7288d3a07d9b5bccb329086e885 (diff)
downloadlua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.tar.gz
lua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.tar.bz2
lua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.zip
Added macro 'luaL_pushfail'
The macro 'luaL_pushfail' documents all places in the standard libraries that return nil to signal some kind of failure. It is defined as 'lua_pushnil'. The manual also got a notation (@fail) to document those returns. The tests were changed to be agnostic regarding whether 'fail' is 'nil' or 'false'.
Diffstat (limited to 'lutf8lib.c')
-rw-r--r--lutf8lib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lutf8lib.c b/lutf8lib.c
index b4b787e7..e63a5a74 100644
--- a/lutf8lib.c
+++ b/lutf8lib.c
@@ -103,7 +103,7 @@ static int utflen (lua_State *L) {
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? */
106 lua_pushnil(L); /* return nil ... */ 106 luaL_pushfail(L); /* return fail ... */
107 lua_pushinteger(L, posi + 1); /* ... and current position */ 107 lua_pushinteger(L, posi + 1); /* ... and current position */
108 return 2; 108 return 2;
109 } 109 }
@@ -216,7 +216,7 @@ static int byteoffset (lua_State *L) {
216 if (n == 0) /* did it find given character? */ 216 if (n == 0) /* did it find given character? */
217 lua_pushinteger(L, posi + 1); 217 lua_pushinteger(L, posi + 1);
218 else /* no such character */ 218 else /* no such character */
219 lua_pushnil(L); 219 luaL_pushfail(L);
220 return 1; 220 return 1;
221} 221}
222 222