From: Paul Eggert Date: Mon, 13 Dec 1999 05:11:05 +0000 (+0000) Subject: (): New include. X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Ftar;a=commitdiff_plain;h=a78ab36e1e4d7dccedaf7d1fcbaca6bb6ec0eed6 (): New include. (append_file): Don't assume that gettext preserves errno. Quote arbitrary strings in diagnostics. Check for close error. --- diff --git a/src/update.c b/src/update.c index f4a1a9d..0f0ebc0 100644 --- a/src/update.c +++ b/src/update.c @@ -21,6 +21,7 @@ they're on raw tape or something like that, it'll probably lose... */ #include "system.h" +#include #include "common.h" /* FIXME: This module should not directly handle the following variable, @@ -50,12 +51,12 @@ append_file (char *path) if (handle < 0) { - ERROR ((0, errno, _("Cannot open file %s"), path)); + open_error (path); return; } if (fstat (handle, &stat_data) != 0) - ERROR ((0, errno, "%s", path)); + stat_error (path); else { off_t bytes_left = stat_data.st_size; @@ -77,14 +78,18 @@ append_file (char *path) status = safe_read (handle, start->buffer, buffer_size); if (status < 0) - FATAL_ERROR ((0, errno, - _("Read error at byte %s reading %lu bytes in file %s"), - STRINGIFY_BIGINT (stat_data.st_size - bytes_left, - buf), - (unsigned long) buffer_size, path)); + { + int e = errno; + FATAL_ERROR ((0, e, + _("Read error at byte %s reading %lu bytes in file %s"), + STRINGIFY_BIGINT (stat_data.st_size - bytes_left, + buf), + (unsigned long) buffer_size, quote (path))); + } if (status == 0) FATAL_ERROR ((0, 0, _("%s: File shrunk by %s bytes, (yark!)"), - path, STRINGIFY_BIGINT (bytes_left, buf))); + quotearg_colon (path), + STRINGIFY_BIGINT (bytes_left, buf))); bytes_left -= status; @@ -92,7 +97,8 @@ append_file (char *path) } } - close (handle); + if (close (handle) != 0) + close_error (path); } /*-----------------------------------------------------------------------.