diff options
author | Avi <avi.ruderam@gmail.com> | 2016-01-08 14:50:59 +0300 |
---|---|---|
committer | avrahamruderman <avi.ruderam@gmail.com> | 2016-01-11 16:05:51 +0300 |
commit | a5a95c36d7db738393f41691c5d68a378a9860c6 (patch) | |
tree | 64dea30776b81d8d4656d3d7e330271b04c3b7d1 | |
parent | be920f1f3829ec8c729950f064108442e1547132 (diff) |
Fix error message when no args are passed
-rw-r--r-- | cinterface.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/cinterface.lua b/cinterface.lua index c6b5c84..e2e2050 100644 --- a/cinterface.lua +++ b/cinterface.lua @@ -118,7 +118,12 @@ function CInterface:__addchelpers() table.insert(txt, '#include "string.h"') table.insert(txt, 'static void str_arg_types(lua_State *L, char *buf, int n) {') table.insert(txt, ' int i;') - table.insert(txt, ' for (i = 1; i <= lua_gettop(L); i++) {') + table.insert(txt, ' int nargs = lua_gettop(L);') + table.insert(txt, ' if (nargs == 0) {') + table.insert(txt, ' snprintf(buf, n, "no arguments provided");') + table.insert(txt, ' return;') + table.insert(txt, ' }') + table.insert(txt, ' for (i = 1; i <= nargs; i++) {') table.insert(txt, ' int l;') table.insert(txt, ' const char *torch_type = luaT_typename(L, i);') table.insert(txt, ' if(torch_type && !strncmp(torch_type, "torch.", 6)) torch_type += 6;') |