Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/cwrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2016-01-11 16:08:23 +0300
committerSoumith Chintala <soumith@gmail.com>2016-01-11 16:08:23 +0300
commitb0a0625ebe21577dd1907002b29b60047d5052ef (patch)
tree64dea30776b81d8d4656d3d7e330271b04c3b7d1
parentbe920f1f3829ec8c729950f064108442e1547132 (diff)
parenta5a95c36d7db738393f41691c5d68a378a9860c6 (diff)
Merge pull request #7 from avrahamruderman/patch-1
fix error message when no argument are passed
-rw-r--r--cinterface.lua7
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;')