summaryrefslogtreecommitdiff
path: root/etc/min.c
diff options
context:
space:
mode:
Diffstat (limited to 'etc/min.c')
-rw-r--r--etc/min.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/etc/min.c b/etc/min.c
index 81e3b73d..0b6a5c32 100644
--- a/etc/min.c
+++ b/etc/min.c
@@ -1,6 +1,6 @@
/*
* min.c -- a minimal Lua interpreter
-* runs one file from the command line or stdin if none given.
+* runs one file from the command line or stdin if no file given.
* minimal error handling, no traceback, no interaction, no standard library,
* only a "print" function.
*/
@@ -15,22 +15,19 @@ static int print(lua_State *L)
{
int n=lua_gettop(L);
int i;
- const char *s="";
for (i=1; i<=n; i++)
- {
- printf("%s%s",s,luaL_tolstring(L,i,NULL));
- s="\t";
- }
+ printf("%s ",luaL_tolstring(L,i,NULL));
printf("\n");
return 0;
}
int main(int argc, char *argv[])
{
- lua_State *L=lua_open();
- lua_register(L,"print",print);
+ lua_State *L=luaL_newstate();
luaL_openlibs(L);
- if (luaL_dofile(L,argv[1])!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1));
+ lua_register(L,"print",print);
+ if (luaL_dofile(L,argv[1])!=0)
+ fprintf(stderr,"%s: %s\n",argv[0],lua_tostring(L,-1));
lua_close(L);
return 0;
}