|
19 | 19 | */ |
20 | 20 |
|
21 | 21 | #define _GNU_SOURCE |
| 22 | +#include <stdarg.h> |
22 | 23 | #include <stdio.h> |
23 | 24 | #include <stdlib.h> |
24 | 25 | #include <string.h> |
@@ -127,9 +128,12 @@ void free_all(void) |
127 | 128 | free(cuefile); |
128 | 129 | } |
129 | 130 |
|
130 | | -void die_format(int status, char *format, char *error) |
| 131 | +void die_format(int status, char *format, ...) |
131 | 132 | { |
132 | | - fprintf(stderr, format, error); |
| 133 | + va_list args; |
| 134 | + va_start(args, format); |
| 135 | + vfprintf(stderr, format, args); |
| 136 | + va_end(args); |
133 | 137 | free_all(); |
134 | 138 | exit(status); |
135 | 139 | } |
@@ -196,8 +200,7 @@ void parse_args(int argc, char *argv[]) |
196 | 200 | basefile = strdup(argv[i]); |
197 | 201 | break; |
198 | 202 | default: |
199 | | - fprintf(stderr, "Gratuitous argument %s\n%s", argv[i], USAGE); |
200 | | - exit(1); |
| 203 | + die_format(1, "Gratuitous argument %s\n%s", argv[i], USAGE); |
201 | 204 | } |
202 | 205 | } |
203 | 206 | } |
@@ -411,8 +414,7 @@ int writetrack(FILE *bf, struct track_t *track) |
411 | 414 | fflush(stdout); |
412 | 415 |
|
413 | 416 | if (ferror(bf)) { |
414 | | - fprintf(stderr, " Could not read from %s: %s\n", binfile, strerror(errno)); |
415 | | - exit(4); |
| 417 | + die_format(4, " Could not read from %s: %s\n", binfile, strerror(errno)); |
416 | 418 | } |
417 | 419 | if (fclose(f)) |
418 | 420 | die_format(4, " Could not fclose track file: %s\n", strerror(errno)); |
|
0 commit comments