diff options
Diffstat (limited to 'auxlib.c')
-rw-r--r-- | auxlib.c | 27 |
1 files changed, 22 insertions, 5 deletions
@@ -1,20 +1,20 @@ | |||
1 | char *rcs_auxlib="$Id: $"; | 1 | char *rcs_auxlib="$Id: auxlib.c,v 1.1 1997/03/17 17:02:29 roberto Exp roberto $"; |
2 | 2 | ||
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <stdarg.h> | ||
4 | 5 | ||
5 | #include "lua.h" | 6 | #include "lua.h" |
7 | #include "auxlib.h" | ||
6 | 8 | ||
7 | 9 | ||
8 | void luaL_arg_check(int cond, char *funcname, int numarg, char *extramsg) | 10 | void luaL_arg_check(int cond, char *funcname, int numarg, char *extramsg) |
9 | { | 11 | { |
10 | if (!cond) { | 12 | if (!cond) { |
11 | char buff[100]; | ||
12 | if (extramsg == NULL) | 13 | if (extramsg == NULL) |
13 | sprintf(buff, "bad argument #%d to function `%s'", numarg, funcname); | 14 | luaL_verror("bad argument #%d to function `%s'", numarg, funcname); |
14 | else | 15 | else |
15 | sprintf(buff, "bad argument #%d to function `%s' (%s)", | 16 | luaL_verror("bad argument #%d to function `%s' (%s)", |
16 | numarg, funcname, extramsg); | 17 | numarg, funcname, extramsg); |
17 | lua_error(buff); | ||
18 | } | 18 | } |
19 | } | 19 | } |
20 | 20 | ||
@@ -45,3 +45,20 @@ double luaL_opt_number (int numArg, double def, char *funcname) | |||
45 | luaL_check_number(numArg, funcname); | 45 | luaL_check_number(numArg, funcname); |
46 | } | 46 | } |
47 | 47 | ||
48 | void luaL_openlib (struct luaL_reg *l, int n) | ||
49 | { | ||
50 | int i; | ||
51 | for (i=0; i<n; i++) | ||
52 | lua_register(l[i].name, l[i].func); | ||
53 | } | ||
54 | |||
55 | |||
56 | void luaL_verror (char *fmt, ...) | ||
57 | { | ||
58 | char buff[1000]; | ||
59 | va_list argp; | ||
60 | va_start(argp, fmt); | ||
61 | vsprintf(buff, fmt, argp); | ||
62 | va_end(argp); | ||
63 | lua_error(buff); | ||
64 | } | ||