diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-01-24 15:04:17 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-01-24 15:04:17 -0300 |
| commit | d69789da1ccfa4db7c241de6b471d6b729f1561e (patch) | |
| tree | bf39e2043cb50b5e4feca0fc7b7323c480337005 /loslib.c | |
| parent | 314745ed8438d1276c6c928d5f9d4be018dfadb6 (diff) | |
| download | lua-d69789da1ccfa4db7c241de6b471d6b729f1561e.tar.gz lua-d69789da1ccfa4db7c241de6b471d6b729f1561e.tar.bz2 lua-d69789da1ccfa4db7c241de6b471d6b729f1561e.zip | |
Fix absence of 'system' in iOS
Despite claiming to be ISO, the C library in some Apple platforms
does not implement 'system'.
Diffstat (limited to 'loslib.c')
| -rw-r--r-- | loslib.c | 18 |
1 files changed, 17 insertions, 1 deletions
| @@ -138,12 +138,28 @@ | |||
| 138 | /* }================================================================== */ | 138 | /* }================================================================== */ |
| 139 | 139 | ||
| 140 | 140 | ||
| 141 | /* | ||
| 142 | ** Despite claiming to be ISO, the C library in some Apple platforms | ||
| 143 | ** does not implement 'system'. | ||
| 144 | */ | ||
| 145 | #if !defined(l_system) && defined(__APPLE__) /* { */ | ||
| 146 | #include "TargetConditionals.h" | ||
| 147 | #if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV | ||
| 148 | #define l_system(cmd) ((cmd) == NULL ? 0 : -1) | ||
| 149 | #endif | ||
| 150 | #endif /* } */ | ||
| 151 | |||
| 152 | #if !defined(l_system) | ||
| 153 | #define l_system(cmd) system(cmd) /* default definition */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | |||
| 141 | 157 | ||
| 142 | static int os_execute (lua_State *L) { | 158 | static int os_execute (lua_State *L) { |
| 143 | const char *cmd = luaL_optstring(L, 1, NULL); | 159 | const char *cmd = luaL_optstring(L, 1, NULL); |
| 144 | int stat; | 160 | int stat; |
| 145 | errno = 0; | 161 | errno = 0; |
| 146 | stat = system(cmd); | 162 | stat = l_system(cmd); |
| 147 | if (cmd != NULL) | 163 | if (cmd != NULL) |
| 148 | return luaL_execresult(L, stat); | 164 | return luaL_execresult(L, stat); |
| 149 | else { | 165 | else { |
