diff options
Diffstat (limited to 'src/bin/pg_dump/compress_io.c')
-rw-r--r-- | src/bin/pg_dump/compress_io.c | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/src/bin/pg_dump/compress_io.c b/src/bin/pg_dump/compress_io.c index d904ec62ad1..a0d7644a8ad 100644 --- a/src/bin/pg_dump/compress_io.c +++ b/src/bin/pg_dump/compress_io.c @@ -74,9 +74,6 @@ struct CompressorState #endif }; -/* translator: this is a module name */ -static const char *modulename = gettext_noop("compress_io"); - static void ParseCompressionOption(int compression, CompressionAlgorithm *alg, int *level); @@ -111,8 +108,7 @@ ParseCompressionOption(int compression, CompressionAlgorithm *alg, int *level) *alg = COMPR_ALG_NONE; else { - exit_horribly(modulename, "invalid compression code: %d\n", - compression); + fatal("invalid compression code: %d", compression); *alg = COMPR_ALG_NONE; /* keep compiler quiet */ } @@ -135,7 +131,7 @@ AllocateCompressor(int compression, WriteFunc writeF) #ifndef HAVE_LIBZ if (alg == COMPR_ALG_LIBZ) - exit_horribly(modulename, "not built with zlib support\n"); + fatal("not built with zlib support"); #endif cs = (CompressorState *) pg_malloc0(sizeof(CompressorState)); @@ -171,7 +167,7 @@ ReadDataFromArchive(ArchiveHandle *AH, int compression, ReadFunc readF) #ifdef HAVE_LIBZ ReadDataFromArchiveZlib(AH, readF); #else - exit_horribly(modulename, "not built with zlib support\n"); + fatal("not built with zlib support"); #endif } } @@ -189,7 +185,7 @@ WriteDataToArchive(ArchiveHandle *AH, CompressorState *cs, #ifdef HAVE_LIBZ WriteDataToArchiveZlib(AH, cs, data, dLen); #else - exit_horribly(modulename, "not built with zlib support\n"); + fatal("not built with zlib support"); #endif break; case COMPR_ALG_NONE: @@ -238,8 +234,7 @@ InitCompressorZlib(CompressorState *cs, int level) cs->zlibOutSize = ZLIB_OUT_SIZE; if (deflateInit(zp, level) != Z_OK) - exit_horribly(modulename, - "could not initialize compression library: %s\n", + fatal("could not initialize compression library: %s", zp->msg); /* Just be paranoid - maybe End is called after Start, with no Write */ @@ -259,8 +254,7 @@ EndCompressorZlib(ArchiveHandle *AH, CompressorState *cs) DeflateCompressorZlib(AH, cs, true); if (deflateEnd(zp) != Z_OK) - exit_horribly(modulename, - "could not close compression stream: %s\n", zp->msg); + fatal("could not close compression stream: %s", zp->msg); free(cs->zlibOut); free(cs->zp); @@ -277,8 +271,7 @@ DeflateCompressorZlib(ArchiveHandle *AH, CompressorState *cs, bool flush) { res = deflate(zp, flush ? Z_FINISH : Z_NO_FLUSH); if (res == Z_STREAM_ERROR) - exit_horribly(modulename, - "could not compress data: %s\n", zp->msg); + fatal("could not compress data: %s", zp->msg); if ((flush && (zp->avail_out < cs->zlibOutSize)) || (zp->avail_out == 0) || (zp->avail_in != 0) @@ -340,8 +333,7 @@ ReadDataFromArchiveZlib(ArchiveHandle *AH, ReadFunc readF) out = pg_malloc(ZLIB_OUT_SIZE + 1); if (inflateInit(zp) != Z_OK) - exit_horribly(modulename, - "could not initialize compression library: %s\n", + fatal("could not initialize compression library: %s", zp->msg); /* no minimal chunk size for zlib */ @@ -357,8 +349,7 @@ ReadDataFromArchiveZlib(ArchiveHandle *AH, ReadFunc readF) res = inflate(zp, 0); if (res != Z_OK && res != Z_STREAM_END) - exit_horribly(modulename, - "could not uncompress data: %s\n", zp->msg); + fatal("could not uncompress data: %s", zp->msg); out[ZLIB_OUT_SIZE - zp->avail_out] = '\0'; ahwrite(out, 1, ZLIB_OUT_SIZE - zp->avail_out, AH); @@ -373,16 +364,14 @@ ReadDataFromArchiveZlib(ArchiveHandle *AH, ReadFunc readF) zp->avail_out = ZLIB_OUT_SIZE; res = inflate(zp, 0); if (res != Z_OK && res != Z_STREAM_END) - exit_horribly(modulename, - "could not uncompress data: %s\n", zp->msg); + fatal("could not uncompress data: %s", zp->msg); out[ZLIB_OUT_SIZE - zp->avail_out] = '\0'; ahwrite(out, 1, ZLIB_OUT_SIZE - zp->avail_out, AH); } if (inflateEnd(zp) != Z_OK) - exit_horribly(modulename, - "could not close compression library: %s\n", zp->msg); + fatal("could not close compression library: %s", zp->msg); free(buf); free(out); @@ -516,7 +505,7 @@ cfopen_write(const char *path, const char *mode, int compression) fp = cfopen(fname, mode, compression); free_keep_errno(fname); #else - exit_horribly(modulename, "not built with zlib support\n"); + fatal("not built with zlib support"); fp = NULL; /* keep compiler quiet */ #endif } @@ -559,7 +548,7 @@ cfopen(const char *path, const char *mode, int compression) fp = NULL; } #else - exit_horribly(modulename, "not built with zlib support\n"); + fatal("not built with zlib support"); #endif } else @@ -596,8 +585,7 @@ cfread(void *ptr, int size, cfp *fp) int errnum; const char *errmsg = gzerror(fp->compressedfp, &errnum); - exit_horribly(modulename, - "could not read from input file: %s\n", + fatal("could not read from input file: %s", errnum == Z_ERRNO ? strerror(errno) : errmsg); } } @@ -634,11 +622,9 @@ cfgetc(cfp *fp) if (ret == EOF) { if (!gzeof(fp->compressedfp)) - exit_horribly(modulename, - "could not read from input file: %s\n", strerror(errno)); + fatal("could not read from input file: %s", strerror(errno)); else - exit_horribly(modulename, - "could not read from input file: end of file\n"); + fatal("could not read from input file: end of file"); } } else |