From e7325c5ace74ea666bc5d962f80c1204dfdd3f2d Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Mon, 22 Aug 2022 15:25:55 +0200 Subject: [PATCH] stdio stdlib: add empty getenv/system/tmpnam/tmpfile for Lua --- CMakeLists.txt | 4 ++++ src/stdio/tmpfile.c | 6 ++++++ src/stdio/tmpnam.c | 7 +++++++ src/stdlib/getenv.c | 7 +++++++ src/stdlib/system.c | 11 +++++++++++ 5 files changed, 35 insertions(+) create mode 100644 src/stdio/tmpfile.c create mode 100644 src/stdio/tmpnam.c create mode 100644 src/stdlib/getenv.c create mode 100644 src/stdlib/system.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 71c6693..9f9882c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,8 @@ set(SOURCES src/stdio/snprintf.c src/stdio/sprintf.c src/stdio/streams.c + src/stdio/tmpfile.c + src/stdio/tmpnam.c src/stdio/ungetc.c src/stdio/vasprintf.c src/stdio/vdprintf.c @@ -162,6 +164,7 @@ set(SOURCES src/stdlib/calloc.c src/stdlib/div.c src/stdlib/exit.c + src/stdlib/getenv.c src/stdlib/labs.c src/stdlib/ldiv.c src/stdlib/llabs.c @@ -177,6 +180,7 @@ set(SOURCES src/stdlib/strtoll.c src/stdlib/strtoul.c src/stdlib/strtoull.c + src/stdlib/system.c # string src/string/memchr.c src/string/memcmp.c diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c new file mode 100644 index 0000000..ff2409f --- /dev/null +++ b/src/stdio/tmpfile.c @@ -0,0 +1,6 @@ +#include + +FILE *tmpfile(void) +{ + return NULL; +} diff --git a/src/stdio/tmpnam.c b/src/stdio/tmpnam.c new file mode 100644 index 0000000..1326f71 --- /dev/null +++ b/src/stdio/tmpnam.c @@ -0,0 +1,7 @@ +#include + +char *tmpnam(char *s) +{ + (void)s; + return NULL; +} diff --git a/src/stdlib/getenv.c b/src/stdlib/getenv.c new file mode 100644 index 0000000..12de5ee --- /dev/null +++ b/src/stdlib/getenv.c @@ -0,0 +1,7 @@ +#include + +char *getenv(char const *name) +{ + (void)name; + return NULL; +} diff --git a/src/stdlib/system.c b/src/stdlib/system.c new file mode 100644 index 0000000..567c9d3 --- /dev/null +++ b/src/stdlib/system.c @@ -0,0 +1,11 @@ +#include + +int system(char const *command) +{ + /* No command: determine whether there is a shell */ + if(!command) + return 0; + + /* Command: pretend it fails and return 1 */ + return 1; +}