From dd669fb9b0423ebbaf8cabc28e46cfa9ea9b6529 Mon Sep 17 00:00:00 2001 From: anth64 Date: Tue, 15 Sep 2026 10:29:45 +0200 Subject: [PATCH] fix: print bare program name in usage instead of argv[0] path --- tools/fpack.c | 14 ++++++++++---- tools/funpack.c | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tools/fpack.c b/tools/fpack.c index 19153d0..84dd837 100644 --- a/tools/fpack.c +++ b/tools/fpack.c @@ -6,6 +6,12 @@ #include #include +#ifdef _WIN32 +#define PROGRAM_NAME "fpack.exe" +#else +#define PROGRAM_NAME "fpack" +#endif + #define FPACK_QUIET (1u << 0) #define FPACK_VERBOSE (1u << 1) #define FPACK_PROGRESS (1u << 2) @@ -200,9 +206,9 @@ static int add_dir(struct fpk_writer *w, const char *dir, size_t base_len) return 1; } -static void usage(const char *name) +static void usage(void) { - fprintf(stderr, "usage: %s [-o output.fpk] [-p] [-q] [-v] input_dir\n", name); + fprintf(stderr, "usage: %s [-o output.fpk] [-p] [-q] [-v] input_dir\n", PROGRAM_NAME); exit(1); } @@ -230,12 +236,12 @@ int main(int argc, char **argv) flags |= FPACK_VERBOSE; break; default: - usage(argv[0]); + usage(); } } if (optind != argc - 1) - usage(argv[0]); + usage(); input_dir = argv[optind]; output = output_arg ? dup_str(output_arg) : derive_output_name(input_dir); diff --git a/tools/funpack.c b/tools/funpack.c index a3793a4..0283331 100644 --- a/tools/funpack.c +++ b/tools/funpack.c @@ -13,6 +13,12 @@ #define MKDIR(path) mkdir(path, 0755) #endif +#ifdef _WIN32 +#define PROGRAM_NAME "funpack.exe" +#else +#define PROGRAM_NAME "funpack" +#endif + #define FUNPACK_LIST (1u << 0) #define FUNPACK_PROGRESS (1u << 1) #define FUNPACK_QUIET (1u << 2) @@ -146,9 +152,9 @@ static int extract_entry(const char *out_dir, const fpk_entry_t *entry, return 1; } -static void usage(const char *name) +static void usage(void) { - fprintf(stderr, "usage: %s [-d output_dir] [-l] [-p] [-q] [-v] input.fpk\n", name); + fprintf(stderr, "usage: %s [-d output_dir] [-l] [-p] [-q] [-v] input.fpk\n", PROGRAM_NAME); exit(1); } @@ -180,12 +186,12 @@ int main(int argc, char **argv) flags |= FUNPACK_VERBOSE; break; default: - usage(argv[0]); + usage(); } } if (optind != argc - 1) - usage(argv[0]); + usage(); input = argv[optind];