diff options
| author | Philipp Janda <siffiejoe@gmx.net> | 2015-05-20 07:25:48 +0200 |
|---|---|---|
| committer | Philipp Janda <siffiejoe@gmx.net> | 2015-05-20 07:25:48 +0200 |
| commit | ba065189ae67822ac9c69cc6ba633e3e8e123ef6 (patch) | |
| tree | 8f064b13129834749ae72c03c15e46ab20adadc2 /tests/testmod.c | |
| parent | ae91294546c2edc60e3349e909740f15c939f1af (diff) | |
| download | lua-compat-5.3-ba065189ae67822ac9c69cc6ba633e3e8e123ef6.tar.gz lua-compat-5.3-ba065189ae67822ac9c69cc6ba633e3e8e123ef6.tar.bz2 lua-compat-5.3-ba065189ae67822ac9c69cc6ba633e3e8e123ef6.zip | |
Add luaL_execresult to C API.
Diffstat (limited to 'tests/testmod.c')
| -rw-r--r-- | tests/testmod.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/testmod.c b/tests/testmod.c index f89b10a..c2dc715 100644 --- a/tests/testmod.c +++ b/tests/testmod.c | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #include <stdio.h> | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> | ||
| 2 | #include <lua.h> | 3 | #include <lua.h> |
| 3 | #include <lauxlib.h> | 4 | #include <lauxlib.h> |
| 4 | #include "compat-5.3.h" | 5 | #include "compat-5.3.h" |
| @@ -256,6 +257,11 @@ static int test_buffer (lua_State *L) { | |||
| 256 | return 1; | 257 | return 1; |
| 257 | } | 258 | } |
| 258 | 259 | ||
| 260 | static int test_exec (lua_State *L) { | ||
| 261 | const char *cmd = luaL_checkstring(L, 1); | ||
| 262 | return luaL_execresult(L, system(cmd)); | ||
| 263 | } | ||
| 264 | |||
| 259 | 265 | ||
| 260 | static const luaL_Reg funcs[] = { | 266 | static const luaL_Reg funcs[] = { |
| 261 | { "isinteger", test_isinteger }, | 267 | { "isinteger", test_isinteger }, |
| @@ -277,6 +283,7 @@ static const luaL_Reg funcs[] = { | |||
| 277 | { "globals", test_globals }, | 283 | { "globals", test_globals }, |
| 278 | { "tolstring", test_tolstring }, | 284 | { "tolstring", test_tolstring }, |
| 279 | { "buffer", test_buffer }, | 285 | { "buffer", test_buffer }, |
| 286 | { "exec", test_exec }, | ||
| 280 | { NULL, NULL } | 287 | { NULL, NULL } |
| 281 | }; | 288 | }; |
| 282 | 289 | ||
