summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--osdep/io.c6
-rw-r--r--osdep/io.h9
-rw-r--r--player/javascript.c2
-rw-r--r--player/lua.c2
4 files changed, 15 insertions, 4 deletions
diff --git a/osdep/io.c b/osdep/io.c
index db61a705fd..d4dcfc6fba 100644
--- a/osdep/io.c
+++ b/osdep/io.c
@@ -682,6 +682,12 @@ char *mp_getenv(const char *name)
return NULL;
}
+char ***mp_penviron()
+{
+ mp_getenv(""); // ensure init
+ return &utf8_environ; // `environ' should be an l-value
+}
+
off_t mp_lseek(int fd, off_t offset, int whence)
{
HANDLE h = (HANDLE)_get_osfhandle(fd);
diff --git a/osdep/io.h b/osdep/io.h
index 12907e5cc9..905558c284 100644
--- a/osdep/io.h
+++ b/osdep/io.h
@@ -105,6 +105,13 @@ int mp_closedir(DIR *dir);
int mp_mkdir(const char *path, int mode);
char *mp_win32_getcwd(char *buf, size_t size);
char *mp_getenv(const char *name);
+
+#ifdef environ /* mingw defines it as _environ */
+#undef environ
+#endif
+#define environ (*mp_penviron()) /* ensure initialization and l-value */
+char ***mp_penviron(void);
+
off_t mp_lseek(int fd, off_t offset, int whence);
// mp_stat types. MSVCRT's dev_t and ino_t are way too short to be unique.
@@ -205,6 +212,8 @@ void freelocale(locale_t);
#include <sys/mman.h>
+extern char **environ;
+
#endif /* __MINGW32__ */
int mp_mkostemps(char *template, int suffixlen, int flags);
diff --git a/player/javascript.c b/player/javascript.c
index e37fcd6c86..be28ef9e66 100644
--- a/player/javascript.c
+++ b/player/javascript.c
@@ -47,8 +47,6 @@
#include "client.h"
#include "libmpv/client.h"
-extern char **environ;
-
// List of builtin modules and their contents as strings.
// All these are generated from player/javascript/*.js
static const char *const builtin_files[][3] = {
diff --git a/player/lua.c b/player/lua.c
index 97ec8d33a4..363e1a52fd 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -53,8 +53,6 @@
#include "client.h"
#include "libmpv/client.h"
-extern char **environ;
-
// List of builtin modules and their contents as strings.
// All these are generated from player/lua/*.lua
static const char * const builtin_lua_scripts[][2] = {