diff options
author | Lua Team <team@lua.org> | 2000-11-06 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2000-11-06 12:00:00 +0000 |
commit | 8cb71cb5548e3138e5d4e4744f52c79d9fafb116 (patch) | |
tree | 25859eb162c67eafc46866e0ec3a9a7ebf93157a /etc/min.c | |
parent | b7610da5fed99f59ac73ae452da8839a0f2c1bda (diff) | |
download | lua-github-4.0.tar.gz |
Lua 4.04.0
Diffstat (limited to 'etc/min.c')
-rw-r--r-- | etc/min.c | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -1,13 +1,32 @@ /* * min.c * a minimal Lua interpreter. loads stdin only. -* no standard library, only builtin functions. +* no standard library, only a "print" function. */ +#include <stdio.h> #include "lua.h" +/* a simple "print". based on the code in lbaselib.c */ +static int print(lua_State *L) +{ + int n=lua_gettop(L); + int i; + for (i=1; i<=n; i++) + { + if (i>1) printf("\t"); + if (lua_isstring(L,i)) + printf("%s",lua_tostring(L,i)); + else + printf("%s:%p",lua_typename(L,lua_type(L,i)),lua_topointer(L,i)); + } + printf("\n"); + return 0; +} + int main(void) { - lua_open(); - return lua_dofile(0); + lua_State *L=lua_open(0); + lua_register(L,"print",print); + return lua_dofile(L,NULL); } |