aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-09-16 16:25:59 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-09-16 16:25:59 -0300
commitc31aa863ac29fad5bb3f44c4e08640f877b65f25 (patch)
tree3eb3fb1dcb50a3b1beefaece33aba00e572e5ad6
parentff08b0f4069e322ec4c2b02aa5553424227357ba (diff)
downloadlua-c31aa863ac29fad5bb3f44c4e08640f877b65f25.tar.gz
lua-c31aa863ac29fad5bb3f44c4e08640f877b65f25.tar.bz2
lua-c31aa863ac29fad5bb3f44c4e08640f877b65f25.zip
Auxiliar functions for building Lua libraries
-rw-r--r--lauxlib.c (renamed from auxlib.c)27
-rw-r--r--lauxlib.h (renamed from auxlib.h)13
2 files changed, 17 insertions, 23 deletions
diff --git a/auxlib.c b/lauxlib.c
index 276fb5f1..37a6e41a 100644
--- a/auxlib.c
+++ b/lauxlib.c
@@ -1,25 +1,20 @@
1char *rcs_auxlib="$Id: auxlib.c,v 1.4 1997/04/07 14:48:53 roberto Exp roberto $"; 1/*
2** $Id: $
3** Auxiliar functions for building Lua libraries
4** See Copyright Notice in lua.h
5*/
6
2 7
3#include <stdio.h>
4#include <stdarg.h> 8#include <stdarg.h>
9#include <stdio.h>
5#include <string.h> 10#include <string.h>
6 11
12#include "lauxlib.h"
7#include "lua.h" 13#include "lua.h"
8#include "auxlib.h"
9#include "luadebug.h" 14#include "luadebug.h"
10 15
11 16
12 17
13int 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
23void luaL_arg_check(int cond, int numarg, char *extramsg) 18void luaL_arg_check(int cond, int numarg, char *extramsg)
24{ 19{
25 if (!cond) { 20 if (!cond) {
@@ -28,9 +23,9 @@ void luaL_arg_check(int cond, int numarg, char *extramsg)
28 if (funcname == NULL) 23 if (funcname == NULL)
29 funcname = "???"; 24 funcname = "???";
30 if (extramsg == NULL) 25 if (extramsg == NULL)
31 luaL_verror("bad argument #%d to function `%s'", numarg, funcname); 26 luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname);
32 else 27 else
33 luaL_verror("bad argument #%d to function `%s' (%s)", 28 luaL_verror("bad argument #%d to function `%.50s' (%.100s)",
34 numarg, funcname, extramsg); 29 numarg, funcname, extramsg);
35 } 30 }
36} 31}
@@ -72,7 +67,7 @@ void luaL_openlib (struct luaL_reg *l, int n)
72 67
73void luaL_verror (char *fmt, ...) 68void luaL_verror (char *fmt, ...)
74{ 69{
75 char buff[1000]; 70 char buff[500];
76 va_list argp; 71 va_list argp;
77 va_start(argp, fmt); 72 va_start(argp, fmt);
78 vsprintf(buff, fmt, argp); 73 vsprintf(buff, fmt, argp);
diff --git a/auxlib.h b/lauxlib.h
index 45cbda9d..9c616c2b 100644
--- a/auxlib.h
+++ b/lauxlib.h
@@ -1,12 +1,17 @@
1/* 1/*
2** $Id: auxlib.h,v 1.2 1997/04/06 14:08:08 roberto Exp roberto $ 2** $Id: $
3** Auxiliar functions for building Lua libraries
4** See Copyright Notice in lua.h
3*/ 5*/
4 6
7
5#ifndef auxlib_h 8#ifndef auxlib_h
6#define auxlib_h 9#define auxlib_h
7 10
11
8#include "lua.h" 12#include "lua.h"
9 13
14
10struct luaL_reg { 15struct luaL_reg {
11 char *name; 16 char *name;
12 lua_CFunction func; 17 lua_CFunction func;
@@ -21,10 +26,4 @@ double luaL_opt_number (int numArg, double def);
21void luaL_verror (char *fmt, ...); 26void luaL_verror (char *fmt, ...);
22 27
23 28
24
25/* -- private part (only for Lua modules */
26
27int luaI_findstring (char *name, char *list[]);
28
29
30#endif 29#endif