aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-11-10 23:16:52 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-11-10 23:16:52 +0300
commit605bd59516b0868cc73ed01f913eeb331033a84b (patch)
tree6745f8d098b70dcdb580764b36117310fd409e8e /src/main.c
parentcdd0133947bf6b8b9679c47e067134db31e0ee48 (diff)
downloadsciteco-605bd59516b0868cc73ed01f913eeb331033a84b.tar.gz
Win32: fixed Unicode commandlines with newer MinGW runtimes
* should also fix Win32 nightly builds * Even though we weren't using main's argv, but were using glib API for retrieving the command line in UTF-8, newer MinGW runtimes would fail when converting the Unicode command line into the system codepage would be lossy. * Most people seem to compile in a "manifest" to work around this issue. But this requires newer Windows versions and using some Microsoft tool which isn't even in $PATH. Instead, we now link with -municode and define wmain() instead, even though we still ignore argv. wmain() proabably get's the command line in UTF-16 and we'd have to convert it anyway. * See https://github.com/msys2/MINGW-packages/issues/22462
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 892f15c..4d0e4e9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <signal.h>
#include <locale.h>
+#include <wchar.h>
#include <glib.h>
#include <glib/gprintf.h>
@@ -299,8 +300,20 @@ teco_sigint_handler(int signal)
teco_interrupted = TRUE;
}
+#ifdef G_OS_WIN32
+/*
+ * We are linking with -municode, since MinGW could otherwise
+ * fail trying to convert Unicode command lines into the system locale.
+ * We still don't use argv since g_win32_get_command_line() returns
+ * an UTF-8 version.
+ * The alternative would be compiling in a manifest.
+ */
+int
+wmain(int argc, wchar_t **argv)
+#else
int
main(int argc, char **argv)
+#endif
{
g_autoptr(GError) error = NULL;