commit d443840846d1cba599dea822697b672c55903e5e
parent 69bee7a3d16169dcd06cd4a98ef012be0d0029f2
Author: Waldemar Celes <celes@tecgraf.puc-rio.br>
Date: Fri, 17 Dec 1993 16:41:01 -0200
Linguagem para Usuarios de Aplicacao
Diffstat:
M | lua.c | | | 41 | +++++++++-------------------------------- |
1 file changed, 9 insertions(+), 32 deletions(-)
diff --git a/lua.c b/lua.c
@@ -1,54 +1,31 @@
/*
** lua.c
** Linguagem para Usuarios de Aplicacao
-** TeCGraf - PUC-Rio
-** 28 Apr 93
*/
+char *rcs_lua="$Id: $";
+
#include <stdio.h>
#include "lua.h"
#include "lualib.h"
-void test (void)
-{
- lua_pushobject(lua_getparam(1));
- lua_call ("c", 1);
-}
-
-
-static void callfunc (void)
-{
- lua_Object obj = lua_getparam (1);
- if (lua_isstring(obj)) lua_call(lua_getstring(obj),0);
-}
-
-static void execstr (void)
-{
- lua_Object obj = lua_getparam (1);
- if (lua_isstring(obj)) lua_dostring(lua_getstring(obj));
-}
-
void main (int argc, char *argv[])
{
int i;
- if (argc < 2)
- {
- puts ("usage: lua filename [functionnames]");
- return;
- }
- lua_register ("callfunc", callfunc);
- lua_register ("execstr", execstr);
- lua_register ("test", test);
iolib_open ();
strlib_open ();
mathlib_open ();
- lua_dofile (argv[1]);
- for (i=2; i<argc; i++)
+ if (argc < 2)
{
- lua_call (argv[i],0);
+ char buffer[250];
+ while (gets(buffer) != 0)
+ lua_dostring(buffer);
}
+ else
+ for (i=1; i<argc; i++)
+ lua_dofile (argv[i]);
}