fix: print bare program name in usage instead of argv[0] path

This commit is contained in:
2026-09-15 10:29:45 +02:00
parent a0a08cb73a
commit dd669fb9b0
2 changed files with 20 additions and 8 deletions
+10 -4
View File
@@ -6,6 +6,12 @@
#include <string.h>
#include <sys/stat.h>
#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);
+10 -4
View File
@@ -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];