diff options
Diffstat (limited to '')
| -rw-r--r-- | util.c | 13 |
1 files changed, 7 insertions, 6 deletions
| @@ -1,4 +1,5 @@ | |||
| 1 | /* See LICENSE file for copyright and license details. */ | 1 | /* See LICENSE file for copyright and license details. */ |
| 2 | #include <errno.h> | ||
| 2 | #include <stdarg.h> | 3 | #include <stdarg.h> |
| 3 | #include <stdio.h> | 4 | #include <stdio.h> |
| 4 | #include <stdlib.h> | 5 | #include <stdlib.h> |
| @@ -10,17 +11,17 @@ void | |||
| 10 | die(const char *fmt, ...) | 11 | die(const char *fmt, ...) |
| 11 | { | 12 | { |
| 12 | va_list ap; | 13 | va_list ap; |
| 14 | int saved_errno; | ||
| 15 | |||
| 16 | saved_errno = errno; | ||
| 13 | 17 | ||
| 14 | va_start(ap, fmt); | 18 | va_start(ap, fmt); |
| 15 | vfprintf(stderr, fmt, ap); | 19 | vfprintf(stderr, fmt, ap); |
| 16 | va_end(ap); | 20 | va_end(ap); |
| 17 | 21 | ||
| 18 | if (fmt[0] && fmt[strlen(fmt)-1] == ':') { | 22 | if (fmt[0] && fmt[strlen(fmt)-1] == ':') |
| 19 | fputc(' ', stderr); | 23 | fprintf(stderr, " %s", strerror(saved_errno)); |
| 20 | perror(NULL); | 24 | fputc('\n', stderr); |
| 21 | } else { | ||
| 22 | fputc('\n', stderr); | ||
| 23 | } | ||
| 24 | 25 | ||
| 25 | exit(1); | 26 | exit(1); |
| 26 | } | 27 | } |
