summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-01-24 15:04:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-01-24 15:04:17 -0300
commitd69789da1ccfa4db7c241de6b471d6b729f1561e (patch)
treebf39e2043cb50b5e4feca0fc7b7323c480337005
parent314745ed8438d1276c6c928d5f9d4be018dfadb6 (diff)
downloadlua-github-d69789da1ccfa4db7c241de6b471d6b729f1561e.tar.gz
Fix absence of 'system' in iOS
Despite claiming to be ISO, the C library in some Apple platforms does not implement 'system'.
-rw-r--r--loslib.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/loslib.c b/loslib.c
index 854dcf69..7eb05caf 100644
--- a/loslib.c
+++ b/loslib.c
@@ -138,12 +138,28 @@
/* }================================================================== */
+/*
+** Despite claiming to be ISO, the C library in some Apple platforms
+** does not implement 'system'.
+*/
+#if !defined(l_system) && defined(__APPLE__) /* { */
+#include "TargetConditionals.h"
+#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
+#define l_system(cmd) ((cmd) == NULL ? 0 : -1)
+#endif
+#endif /* } */
+
+#if !defined(l_system)
+#define l_system(cmd) system(cmd) /* default definition */
+#endif
+
+
static int os_execute (lua_State *L) {
const char *cmd = luaL_optstring(L, 1, NULL);
int stat;
errno = 0;
- stat = system(cmd);
+ stat = l_system(cmd);
if (cmd != NULL)
return luaL_execresult(L, stat);
else {