Skip to content

Commit cae1ce9

Browse files
committed
use return lua_error idiom
1 parent 454f7f3 commit cae1ce9

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));
@@ -359,7 +359,7 @@ static int regexp_tostring(lua_State *lstate) {
359359
static int match_tostring(lua_State *lstate) {
360360
// luaL_getmetatable(lstate, JSREGEXP_MATCH);
361361
// if (!lua_getmetatable(lstate, 1) || !lua_equal(lstate, -1, -2)) {
362-
// luaL_argerror(lstate, 1, "match object expected");
362+
// return luaL_argerror(lstate, 1, "match object expected");
363363
// }
364364
lua_rawgeti(lstate, 1, 0);
365365
return 1;
@@ -408,7 +408,7 @@ static int regexp_exec(lua_State *lstate) {
408408
input->len, input->is_wide_char ? 1 : 0, NULL);
409409

410410
if (ret < 0) {
411-
luaL_error(lstate, "out of memory in regexp execution");
411+
return luaL_error(lstate, "out of memory in regexp execution");
412412
}
413413

414414
if (ret == 0) {
@@ -598,7 +598,7 @@ static int regexp_newindex(lua_State *lstate) {
598598
luaL_argcheck(lstate, ind >= 1, 3, "last_index must be positive");
599599
r->last_index = ind - 1;
600600
} else {
601-
luaL_argerror(lstate, 2, "unrecognized key");
601+
return luaL_argerror(lstate, 2, "unrecognized key");
602602
}
603603

604604
return 0;
@@ -622,7 +622,7 @@ static int jsregexp_compile(lua_State *lstate) {
622622
// lre_compile can segfault if the input contains 0x8f, which
623623
// indicated the beginning of a six byte sequence, but is now illegal.
624624
if (strchr(regexp, 0xfd)) {
625-
luaL_argerror(lstate, 1, "malformed unicode");
625+
return luaL_argerror(lstate, 1, "malformed unicode");
626626
}
627627

628628
if (utf8_contains_non_bmp(regexp)) {
@@ -667,7 +667,7 @@ static int jsregexp_compile(lua_State *lstate) {
667667
strlen(regexp), re_flags, NULL);
668668

669669
if (!bc) {
670-
luaL_argerror(lstate, 1, error_msg);
670+
return luaL_argerror(lstate, 1, error_msg);
671671
}
672672

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

0 commit comments

Comments
 (0)