Software /
code /
prosody
Comparison
util-src/signal.c @ 6620:50eaefeec013
util-src/*.c: Per convention call luaL_error() as argument to return
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 03 Apr 2015 20:30:14 +0200 |
parent | 6615:8e4572a642cb |
child | 6789:6b180e77c97a |
comparison
equal
deleted
inserted
replaced
6619:78d1706982b2 | 6620:50eaefeec013 |
---|---|
235 lua_gettable(L, LUA_REGISTRYINDEX); | 235 lua_gettable(L, LUA_REGISTRYINDEX); |
236 lua_pushvalue(L, 1); | 236 lua_pushvalue(L, 1); |
237 lua_gettable(L, -2); | 237 lua_gettable(L, -2); |
238 | 238 |
239 if(!lua_isnumber(L, -1)) { | 239 if(!lua_isnumber(L, -1)) { |
240 luaL_error(L, "invalid signal string"); | 240 return luaL_error(L, "invalid signal string"); |
241 } | 241 } |
242 | 242 |
243 sig = (int) lua_tonumber(L, -1); | 243 sig = (int) lua_tonumber(L, -1); |
244 lua_pop(L, 1); /* get rid of number we pushed */ | 244 lua_pop(L, 1); /* get rid of number we pushed */ |
245 } else { | 245 } else { |
246 luaL_checknumber(L, 1); /* will always error, with good error msg */ | 246 luaL_checknumber(L, 1); /* will always error, with good error msg */ |
247 return luaL_error(L, "unreachable: invalid number was accepted"); | |
247 } | 248 } |
248 | 249 |
249 /* set handler */ | 250 /* set handler */ |
250 if(args == 1 || lua_isnil(L, 2)) { /* clear handler */ | 251 if(args == 1 || lua_isnil(L, 2)) { /* clear handler */ |
251 lua_pushstring(L, LUA_SIGNAL); | 252 lua_pushstring(L, LUA_SIGNAL); |
311 lua_gettable(L, LUA_REGISTRYINDEX); | 312 lua_gettable(L, LUA_REGISTRYINDEX); |
312 lua_pushvalue(L, 1); | 313 lua_pushvalue(L, 1); |
313 lua_gettable(L, -2); | 314 lua_gettable(L, -2); |
314 | 315 |
315 if(!lua_isnumber(L, -1)) { | 316 if(!lua_isnumber(L, -1)) { |
316 luaL_error(L, "invalid signal string"); | 317 return luaL_error(L, "invalid signal string"); |
317 } | 318 } |
318 | 319 |
319 ret = (lua_Number) raise((int) lua_tonumber(L, -1)); | 320 ret = (lua_Number) raise((int) lua_tonumber(L, -1)); |
320 lua_pop(L, 1); /* get rid of number we pushed */ | 321 lua_pop(L, 1); /* get rid of number we pushed */ |
321 lua_pushnumber(L, ret); | 322 lua_pushnumber(L, ret); |
355 lua_gettable(L, LUA_REGISTRYINDEX); | 356 lua_gettable(L, LUA_REGISTRYINDEX); |
356 lua_pushvalue(L, 2); | 357 lua_pushvalue(L, 2); |
357 lua_gettable(L, -2); | 358 lua_gettable(L, -2); |
358 | 359 |
359 if(!lua_isnumber(L, -1)) { | 360 if(!lua_isnumber(L, -1)) { |
360 luaL_error(L, "invalid signal string"); | 361 return luaL_error(L, "invalid signal string"); |
361 } | 362 } |
362 | 363 |
363 ret = (lua_Number) kill((int) lua_tonumber(L, 1), | 364 ret = (lua_Number) kill((int) lua_tonumber(L, 1), |
364 (int) lua_tonumber(L, -1)); | 365 (int) lua_tonumber(L, -1)); |
365 lua_pop(L, 1); /* get rid of number we pushed */ | 366 lua_pop(L, 1); /* get rid of number we pushed */ |