Skip to content

Commit d1bda17

Browse files
committed
use return lua_error idiom
1 parent d62ca16 commit d1bda17

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

jsregexp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static int jsstring_new(lua_State *lstate) {
135135
&indices, &rev_indices);
136136

137137
if (!input_utf16) {
138-
luaL_error(lstate, "malformed unicode");
138+
return luaL_error(lstate, "malformed unicode");
139139
}
140140

141141
ud = lua_newuserdata(lstate, sizeof(*ud));
@@ -221,7 +221,7 @@ static int regexp_tostring(lua_State *lstate) {
221221
static int match_tostring(lua_State *lstate) {
222222
// luaL_getmetatable(lstate, JSREGEXP_MATCH);
223223
// if (!lua_getmetatable(lstate, 1) || !lua_equal(lstate, -1, -2)) {
224-
// luaL_argerror(lstate, 1, "match object expected");
224+
// return luaL_argerror(lstate, 1, "match object expected");
225225
// }
226226
lua_rawgeti(lstate, 1, 0);
227227
return 1;
@@ -270,7 +270,7 @@ static int regexp_exec(lua_State *lstate) {
270270
input->len, input->is_wide_char ? 1 : 0, NULL);
271271

272272
if (ret < 0) {
273-
luaL_error(lstate, "out of memory in regexp execution");
273+
return luaL_error(lstate, "out of memory in regexp execution");
274274
}
275275

276276
if (ret == 0) {
@@ -460,7 +460,7 @@ static int regexp_newindex(lua_State *lstate) {
460460
luaL_argcheck(lstate, ind >= 1, 3, "last_index must be positive");
461461
r->last_index = ind - 1;
462462
} else {
463-
luaL_argerror(lstate, 2, "unrecognized key");
463+
return luaL_argerror(lstate, 2, "unrecognized key");
464464
}
465465

466466
return 0;
@@ -483,7 +483,7 @@ static int jsregexp_compile(lua_State *lstate) {
483483
// lre_compile can segfault if the input contains 0x8f, which
484484
// indicated the beginning of a six byte sequence, but is now illegal.
485485
if (strchr(regexp, 0xfd)) {
486-
luaL_argerror(lstate, 1, "malformed unicode");
486+
return luaL_argerror(lstate, 1, "malformed unicode");
487487
}
488488

489489
if (utf8_contains_non_bmp(regexp)) {
@@ -528,7 +528,7 @@ static int jsregexp_compile(lua_State *lstate) {
528528
strlen(regexp), re_flags, NULL);
529529

530530
if (!bc) {
531-
luaL_argerror(lstate, 1, error_msg);
531+
return luaL_argerror(lstate, 1, error_msg);
532532
}
533533

534534
struct regexp *ud = lua_newuserdata(lstate, sizeof *ud);

0 commit comments

Comments
 (0)