diff --git a/src/patch.c b/src/patch.c index e6abd3a..d0c75ac 100644 --- a/src/patch.c +++ b/src/patch.c @@ -1321,19 +1321,6 @@ print_unidiff_range (FILE *fp, lin start, lin count) } } -/* Output to FP a line containing the concatenation of the remaining - string arguments. A null pointer terminates the string args. */ -static void -putline (FILE *fp, ...) -{ - va_list ap; - va_start (ap, fp); - for (char *arg; (arg = va_arg (ap, char *)); ) - fputs (arg, fp); - va_end (ap); - putc ('\n', fp); -} - static void print_header_line (FILE *fp, const char *tag, bool reverse) { diff --git a/src/pch.c b/src/pch.c index 35f839f..eb71152 100644 --- a/src/pch.c +++ b/src/pch.c @@ -297,10 +297,11 @@ there_is_another_patch (bool need_header, mode_t *file_type) inerrno = stat_file (inname, &instat); if (inerrno) { - perror (inname); + fputs (inname, stderr); + putline (stderr, ": ", strerror (inerrno), nullptr); fflush (stderr); free (inname); - inname = 0; + inname = nullptr; } else invc = -1; diff --git a/src/util.c b/src/util.c index 78c107c..6e1ffce 100644 --- a/src/util.c +++ b/src/util.c @@ -992,6 +992,19 @@ write_fatal (void) pfatal ("write error"); } +/* Output to FP a line containing the concatenation of the remaining + string arguments. A null pointer terminates the string args. */ +void +putline (FILE *fp, ...) +{ + va_list ap; + va_start (ap, fp); + for (char *arg; (arg = va_arg (ap, char *)); ) + fputs (arg, fp); + va_end (ap); + putc ('\n', fp); +} + /* Say something from patch, something from the system, then silence . . . */ void @@ -1004,9 +1017,7 @@ pfatal (char const *format, ...) va_start (args, format); vfprintf (stderr, format, args); va_end (args); - fflush (stderr); /* perror bypasses stdio on some hosts. */ - errno = errnum; - perror (" "); + putline (stderr, " : ", strerror (errnum), nullptr); fflush (stderr); fatal_exit (0); } diff --git a/src/util.h b/src/util.h index b59175d..3e686ff 100644 --- a/src/util.h +++ b/src/util.h @@ -64,6 +64,7 @@ void read_fatal (void) __attribute__ ((noreturn)); void remove_prefix (char *, size_t); void removedirs (char const *); void write_fatal (void) __attribute__ ((noreturn)); +void putline (FILE *, ...); void insert_file_id (struct stat const *, enum file_id_type); enum file_id_type lookup_file_id (struct stat const *); void set_queued_output (struct stat const *, bool);