diff options
Diffstat (limited to 'auxlib.c')
| -rw-r--r-- | auxlib.c | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/auxlib.c b/auxlib.c deleted file mode 100644 index 276fb5f1..00000000 --- a/auxlib.c +++ /dev/null | |||
| @@ -1,81 +0,0 @@ | |||
| 1 | char *rcs_auxlib="$Id: auxlib.c,v 1.4 1997/04/07 14:48:53 roberto Exp roberto $"; | ||
| 2 | |||
| 3 | #include <stdio.h> | ||
| 4 | #include <stdarg.h> | ||
| 5 | #include <string.h> | ||
| 6 | |||
| 7 | #include "lua.h" | ||
| 8 | #include "auxlib.h" | ||
| 9 | #include "luadebug.h" | ||
| 10 | |||
| 11 | |||
| 12 | |||
| 13 | int luaI_findstring (char *name, char *list[]) | ||
| 14 | { | ||
| 15 | int i; | ||
| 16 | for (i=0; list[i]; i++) | ||
| 17 | if (strcmp(list[i], name) == 0) | ||
| 18 | return i; | ||
| 19 | return -1; /* name not found */ | ||
| 20 | } | ||
| 21 | |||
| 22 | |||
| 23 | void luaL_arg_check(int cond, int numarg, char *extramsg) | ||
| 24 | { | ||
| 25 | if (!cond) { | ||
| 26 | char *funcname; | ||
| 27 | lua_getobjname(lua_stackedfunction(0), &funcname); | ||
| 28 | if (funcname == NULL) | ||
| 29 | funcname = "???"; | ||
| 30 | if (extramsg == NULL) | ||
| 31 | luaL_verror("bad argument #%d to function `%s'", numarg, funcname); | ||
| 32 | else | ||
| 33 | luaL_verror("bad argument #%d to function `%s' (%s)", | ||
| 34 | numarg, funcname, extramsg); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | char *luaL_check_string (int numArg) | ||
| 39 | { | ||
| 40 | lua_Object o = lua_getparam(numArg); | ||
| 41 | luaL_arg_check(lua_isstring(o), numArg, "string expected"); | ||
| 42 | return lua_getstring(o); | ||
| 43 | } | ||
| 44 | |||
| 45 | char *luaL_opt_string (int numArg, char *def) | ||
| 46 | { | ||
| 47 | return (lua_getparam(numArg) == LUA_NOOBJECT) ? def : | ||
| 48 | luaL_check_string(numArg); | ||
| 49 | } | ||
| 50 | |||
| 51 | double luaL_check_number (int numArg) | ||
| 52 | { | ||
| 53 | lua_Object o = lua_getparam(numArg); | ||
| 54 | luaL_arg_check(lua_isnumber(o), numArg, "number expected"); | ||
| 55 | return lua_getnumber(o); | ||
| 56 | } | ||
| 57 | |||
| 58 | |||
| 59 | double luaL_opt_number (int numArg, double def) | ||
| 60 | { | ||
| 61 | return (lua_getparam(numArg) == LUA_NOOBJECT) ? def : | ||
| 62 | luaL_check_number(numArg); | ||
| 63 | } | ||
| 64 | |||
| 65 | void luaL_openlib (struct luaL_reg *l, int n) | ||
| 66 | { | ||
| 67 | int i; | ||
| 68 | for (i=0; i<n; i++) | ||
| 69 | lua_register(l[i].name, l[i].func); | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | void luaL_verror (char *fmt, ...) | ||
| 74 | { | ||
| 75 | char buff[1000]; | ||
| 76 | va_list argp; | ||
| 77 | va_start(argp, fmt); | ||
| 78 | vsprintf(buff, fmt, argp); | ||
| 79 | va_end(argp); | ||
| 80 | lua_error(buff); | ||
| 81 | } | ||
