diff --git a/lib/util.c b/lib/util.c index 984ab4570..0ebf0852f 100644 --- a/lib/util.c +++ b/lib/util.c @@ -373,11 +373,18 @@ void set_program_name__(const char *argv0, const char *version, const char *date, const char *time) { - const char *slash = strrchr(argv0, '/'); - +#ifdef _WIN32 + char *basename; + size_t max_len = strlen(argv0) + 1; + basename = xmalloc(max_len); + _splitpath_s(argv0, NULL, 0, NULL, 0, basename, max_len, NULL, 0); + assert_single_threaded(); + program_name = basename; +#else + const char *slash = strrchr(argv0, '/'); assert_single_threaded(); - program_name = slash ? slash + 1 : argv0; +#endif free(program_version);