@@ -93,7 +93,7 @@ static int l_checkmode (const char *mode) {
9393
9494#if !defined(l_getc ) /* { */
9595
96- #if defined(LUA_USE_POSIX )
96+ #if defined(LUA_USE_POSIX ) && !defined( __wasi__ )
9797#define l_getc (f ) getc_unlocked(f)
9898#define l_lockfile (f ) flockfile(f)
9999#define l_unlockfile (f ) funlockfile(f)
@@ -280,14 +280,17 @@ static int io_open (lua_State *L) {
280280/*
281281** function to close 'popen' files
282282*/
283+ #if !defined(__wasi__ )
283284static int io_pclose (lua_State * L ) {
284285 LStream * p = tolstream (L );
285286 errno = 0 ;
286287 return luaL_execresult (L , l_pclose (L , p -> f ));
287288}
289+ #endif
288290
289291
290292static int io_popen (lua_State * L ) {
293+ #if !defined(__wasi__ )
291294 const char * filename = luaL_checkstring (L , 1 );
292295 const char * mode = luaL_optstring (L , 2 , "r" );
293296 LStream * p = newprefile (L );
@@ -296,14 +299,21 @@ static int io_popen (lua_State *L) {
296299 p -> f = l_popen (L , filename , mode );
297300 p -> closef = & io_pclose ;
298301 return (p -> f == NULL ) ? luaL_fileresult (L , 0 , filename ) : 1 ;
302+ #else
303+ luaL_error (L , "not supported on WASI" );
304+ #endif
299305}
300306
301307
302308static int io_tmpfile (lua_State * L ) {
309+ #if !defined(__wasi__ )
303310 LStream * p = newfile (L );
304311 errno = 0 ;
305312 p -> f = tmpfile ();
306313 return (p -> f == NULL ) ? luaL_fileresult (L , 0 , NULL ) : 1 ;
314+ #else
315+ luaL_error (L , "not supported on WASI" );
316+ #endif
307317}
308318
309319
0 commit comments