From 557e9d95317baf54e035e4fabfd45b15e6d6e708 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Wed, 5 Aug 2020 14:57:23 +0300 Subject: win32: scripting utils.get_env_list(): use UTF-8 lua/js utils.get_env_list() uses `environ' which was ANSI, thus it broke any unicode names/values. mpv already has an internal utf8_environ for win32, but it's used only at the getenv(..) wrapper and not exposed in itself, and also it has lazy initialization - on first getenv() call. Now `environ' maps to a function which ensures initialization while keeping it an l-value (like posix expects). The cost of this fuglyness is that files should include osdep/io.h (which now declares environ as extern) rather than declaring it themselves, or else the build will break on mingw. --- osdep/io.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'osdep/io.c') 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); -- cgit v1.2.3