From c31aa863ac29fad5bb3f44c4e08640f877b65f25 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 16 Sep 1997 16:25:59 -0300 Subject: [PATCH] Auxiliar functions for building Lua libraries --- auxlib.c => lauxlib.c | 27 +++++++++++---------------- auxlib.h => lauxlib.h | 13 ++++++------- 2 files changed, 17 insertions(+), 23 deletions(-) rename auxlib.c => lauxlib.c (75%) rename auxlib.h => lauxlib.h (73%) diff --git a/auxlib.c b/lauxlib.c similarity index 75% rename from auxlib.c rename to lauxlib.c index 276fb5f1..37a6e41a 100644 --- a/auxlib.c +++ b/lauxlib.c @@ -1,25 +1,20 @@ -char *rcs_auxlib="$Id: auxlib.c,v 1.4 1997/04/07 14:48:53 roberto Exp roberto $"; +/* +** $Id: $ +** Auxiliar functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + -#include #include +#include #include +#include "lauxlib.h" #include "lua.h" -#include "auxlib.h" #include "luadebug.h" -int luaI_findstring (char *name, char *list[]) -{ - int i; - for (i=0; list[i]; i++) - if (strcmp(list[i], name) == 0) - return i; - return -1; /* name not found */ -} - - void luaL_arg_check(int cond, int numarg, char *extramsg) { if (!cond) { @@ -28,9 +23,9 @@ void luaL_arg_check(int cond, int numarg, char *extramsg) if (funcname == NULL) funcname = "???"; if (extramsg == NULL) - luaL_verror("bad argument #%d to function `%s'", numarg, funcname); + luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname); else - luaL_verror("bad argument #%d to function `%s' (%s)", + luaL_verror("bad argument #%d to function `%.50s' (%.100s)", numarg, funcname, extramsg); } } @@ -72,7 +67,7 @@ void luaL_openlib (struct luaL_reg *l, int n) void luaL_verror (char *fmt, ...) { - char buff[1000]; + char buff[500]; va_list argp; va_start(argp, fmt); vsprintf(buff, fmt, argp); diff --git a/auxlib.h b/lauxlib.h similarity index 73% rename from auxlib.h rename to lauxlib.h index 45cbda9d..9c616c2b 100644 --- a/auxlib.h +++ b/lauxlib.h @@ -1,12 +1,17 @@ /* -** $Id: auxlib.h,v 1.2 1997/04/06 14:08:08 roberto Exp roberto $ +** $Id: $ +** Auxiliar functions for building Lua libraries +** See Copyright Notice in lua.h */ + #ifndef auxlib_h #define auxlib_h + #include "lua.h" + struct luaL_reg { char *name; lua_CFunction func; @@ -21,10 +26,4 @@ double luaL_opt_number (int numArg, double def); void luaL_verror (char *fmt, ...); - -/* -- private part (only for Lua modules */ - -int luaI_findstring (char *name, char *list[]); - - #endif