diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-12-11 21:19:09 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-12-12 09:31:37 +0000 |
commit | b85f0cbc2f7b412862f9f84faab4815a534dcc2f (patch) | |
tree | 9220f108a8967dd8f741d5b3ee1aa10204fb83a1 /reordercap.c | |
parent | 541fe1d93795327e8f4b0b3b4bec58fef15f34d6 (diff) |
Properly convert command-line arguments to UTF-8 on Windows.
Do the same thing we do for most other command-line programs - on
Windows, have wmain() rather than main(), convert the UTF-16 argument
lists to UTF-8, and pass them on to real_main(), otherwise just have
main() call real_main(). That way, they never pass through the local
code page on Windows.
Change-Id: Ib74176dd0586c012eabaa3376c1d7dcba8838978
Reviewed-on: https://code.wireshark.org/review/31014
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'reordercap.c')
-rw-r--r-- | reordercap.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/reordercap.c b/reordercap.c index 93e2d1bb8d..56d4ae5e33 100644 --- a/reordercap.c +++ b/reordercap.c @@ -30,6 +30,7 @@ #include <wsutil/filesystem.h> #include <wsutil/file_util.h> #include <wsutil/privileges.h> +#include <wsutil/unicode-utils.h> #include <version_info.h> #include <wiretap/wtap_opttypes.h> @@ -160,8 +161,8 @@ failure_message_cont(const char *msg_format, va_list ap) /********************************************************************/ /* Main function. */ /********************************************************************/ -int -main(int argc, char *argv[]) +static int +real_main(int argc, char *argv[]) { GString *comp_info_str; GString *runtime_info_str; @@ -379,6 +380,23 @@ clean_exit: return ret; } +#ifdef _WIN32 +int +wmain(int argc, wchar_t *wc_argv[]) +{ + char **argv; + + argv = arg_list_utf_16to8(argc, wc_argv); + return real_main(argc, argv); +} +#else +int +main(int argc, char *argv[]) +{ + return real_main(argc, argv); +} +#endif + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * |