From 1f98eff33a805f0e1de1bc90422e9d32d039cbe4 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 5 Jan 2019 20:52:32 -0500 Subject: [PATCH] Fix compiler warnings on emscripten. --- src/core/capi.c | 2 +- src/core/io.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/capi.c b/src/core/capi.c index 622ef91f..15b2b274 100644 --- a/src/core/capi.c +++ b/src/core/capi.c @@ -165,7 +165,7 @@ JanetRange janet_getslice(int32_t argc, const Janet *argv) { if (range.start < 0 || range.start > length) { janet_panicf("slice start: index %d out of range [0,%d]", range.start, length); } - } else if (argc == 3) { + } else { range.start = janet_getinteger(argv, 1); range.end = janet_getinteger(argv, 2); if (range.start < 0) { diff --git a/src/core/io.c b/src/core/io.c index a435d6c4..71abcbfc 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -99,6 +99,14 @@ static Janet makef(FILE *f, int flags) { } /* Open a process */ +#ifdef __EMSCRIPTEN__ +static Janet janet_io_popen(int32_t argc, Janet *argv) { + (void) argc; + (void) argv; + janet_panic("not implemented on this platform"); + return janet_wrap_nil(); +} +#else static Janet janet_io_popen(int32_t argc, Janet *argv) { janet_arity(argc, 1, 2); const uint8_t *fname = janet_getstring(argv, 0); @@ -115,9 +123,6 @@ static Janet janet_io_popen(int32_t argc, Janet *argv) { : IO_PIPED | IO_READ; #ifdef JANET_WINDOWS #define popen _popen -#endif -#ifdef __EMSCRIPTEN__ -#define popen(A, B) (errno = 0, NULL) #endif FILE *f = popen((const char *)fname, (const char *)fmode); if (!f) { @@ -125,6 +130,7 @@ static Janet janet_io_popen(int32_t argc, Janet *argv) { } return makef(f, flags); } +#endif /* Open a a file and return a userdata wrapper around the C file API. */ static Janet janet_io_fopen(int32_t argc, Janet *argv) {