Aegisub/vendor/luajit/unicode-os.patch

29 lines
875 B
Diff
Raw Normal View History

2015-09-12 12:45:23 +02:00
diff --git a/vendor/luajit/src/lib_os.c b/vendor/luajit/src/lib_os.c
index bb5a141..a2ed170 100644
--- a/vendor/luajit/src/lib_os.c
+++ b/vendor/luajit/src/lib_os.c
2019-09-15 00:33:59 +02:00
@@ -35,6 +35,23 @@
/* ------------------------------------------------------------------------ */
+#if LJ_TARGET_WINDOWS
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+static wchar_t *widen_static(const char *narrow, int idx)
+{
+ __declspec(thread) static wchar_t buffer[2][MAX_PATH];
+ return MultiByteToWideChar(CP_UTF8, 0, narrow, -1, buffer[idx], MAX_PATH) ? buffer[idx] : L"";
+}
+
+#define remove(x) _wremove(widen_static(x, 0))
+#define system(x) _wsystem(widen_static(x, 0))
+#define rename(x, y) _wrename(widen_static(x, 0), widen_static(y, 1))
+#endif
+
+/* ------------------------------------------------------------------------ */
+
#define LJLIB_MODULE_os
LJLIB_CF(os_execute)