diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-11-29 20:41:06 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-11-29 20:41:54 -0500 |
commit | 0195e5c4ab1ac710b280f7834202a7164058379c (patch) | |
tree | 4321c3ea9dd9226f53119385e58c519cfc1947c0 /src/bin/pg_dump/dumputils.c | |
parent | 2ff36abeec948899b9a51d1c945e9fbe85e056d5 (diff) | |
download | postgresql-0195e5c4ab1ac710b280f7834202a7164058379c.tar.gz postgresql-0195e5c4ab1ac710b280f7834202a7164058379c.zip |
Clean up after recent pg_dump patches.
Fix entirely broken handling of va_list printing routines, update some
out-of-date comments, fix some bogus inclusion orders, fix NLS declarations,
fix missed realloc calls.
Diffstat (limited to 'src/bin/pg_dump/dumputils.c')
-rw-r--r-- | src/bin/pg_dump/dumputils.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 39601e6a5fc..5dab9675fc0 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -16,14 +16,14 @@ #include <ctype.h> -#include "dumpmem.h" #include "dumputils.h" #include "parser/keywords.h" +/* Globals exported by this file */ int quote_all_identifiers = 0; -const char *progname; +const char *progname = NULL; #define supports_grant_options(version) ((version) >= 70400) @@ -1214,31 +1214,51 @@ emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer, } +/* + * Write a printf-style message to stderr. + * + * The program name is prepended, if "progname" has been set. + * Also, if modulename isn't NULL, that's included too. + * Note that we'll try to translate the modulename and the fmt string. + */ void write_msg(const char *modulename, const char *fmt,...) { va_list ap; va_start(ap, fmt); - if (modulename) - fprintf(stderr, "%s: [%s] ", progname, _(modulename)); - else - fprintf(stderr, "%s: ", progname); - vfprintf(stderr, _(fmt), ap); + vwrite_msg(modulename, fmt, ap); va_end(ap); } +/* + * As write_msg, but pass a va_list not variable arguments. + */ +void +vwrite_msg(const char *modulename, const char *fmt, va_list ap) +{ + if (progname) + { + if (modulename) + fprintf(stderr, "%s: [%s] ", progname, _(modulename)); + else + fprintf(stderr, "%s: ", progname); + } + vfprintf(stderr, _(fmt), ap); +} + +/* + * Fail and die, with a message to stderr. Parameters as for write_msg. + */ void exit_horribly(const char *modulename, const char *fmt,...) { va_list ap; va_start(ap, fmt); - write_msg(modulename, fmt, ap); + vwrite_msg(modulename, fmt, ap); va_end(ap); exit(1); } - - |