blob: ac08668272bbec3c657a078f36b67fc2fa78c250 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include <stdio.h>
#include <string.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
int main(int argc, char **argv)
{
char buffer[256];
int error;
lua_State *L = luaL_newstate();
luaL_openlibs(L);
while (fgets(buffer, sizeof(buffer), stdin) != NULL) {
error = luaL_loadbuffer(L, buffer, strlen(buffer), "line")
|| lua_pcall(L, 0, 0, 0);
if (error) {
fprintf(stderr, "%s", lua_tostring(L, -1));
lua_pop(L, 1);
}
}
lua_close(L);
return 0;
}
|