|
|
|
@ -152,7 +152,7 @@ static void check_opt(const struct opt_table *entry)
@@ -152,7 +152,7 @@ static void check_opt(const struct opt_table *entry)
|
|
|
|
|
|
|
|
|
|
static void add_opt(const struct opt_table *entry) |
|
|
|
|
{ |
|
|
|
|
opt_table = realloc(opt_table, sizeof(opt_table[0]) * (opt_count+1)); |
|
|
|
|
opt_table = (struct opt_table *)realloc(opt_table, sizeof(opt_table[0]) * (opt_count + 1)); |
|
|
|
|
opt_table[opt_count++] = *entry; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -202,19 +202,19 @@ bool opt_parse(int *argc, char *argv[], void (*errlog)(const char *fmt, ...))
@@ -202,19 +202,19 @@ bool opt_parse(int *argc, char *argv[], void (*errlog)(const char *fmt, ...))
|
|
|
|
|
int ret; |
|
|
|
|
unsigned offset = 0; |
|
|
|
|
|
|
|
|
|
#ifdef WIN32 |
|
|
|
|
#if defined(WIN32) && !defined(_MSC_VER) |
|
|
|
|
char *original_argv0 = argv[0]; |
|
|
|
|
argv[0] = (char*)basename(argv[0]); |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/* This helps opt_usage. */ |
|
|
|
|
opt_argv0 = argv[0]; |
|
|
|
|
|
|
|
|
|
while ((ret = parse_one(argc, argv, &offset, errlog)) == 1); |
|
|
|
|
|
|
|
|
|
#ifdef WIN32 |
|
|
|
|
#if defined(WIN32) && !defined(_MSC_VER) |
|
|
|
|
argv[0] = original_argv0; |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/* parse_one returns 0 on finish, -1 on error */ |
|
|
|
|
return (ret == 0); |
|
|
|
@ -249,7 +249,7 @@ void opt_log_stderr_exit(const char *fmt, ...)
@@ -249,7 +249,7 @@ void opt_log_stderr_exit(const char *fmt, ...)
|
|
|
|
|
|
|
|
|
|
char *opt_invalid_argument(const char *arg) |
|
|
|
|
{ |
|
|
|
|
char *str = malloc(sizeof("Invalid argument '%s'") + strlen(arg)); |
|
|
|
|
char *str = (char *)malloc(sizeof("Invalid argument '%s'") + strlen(arg)); |
|
|
|
|
sprintf(str, "Invalid argument '%s'", arg); |
|
|
|
|
return str; |
|
|
|
|
} |
|
|
|
|