Re: [HACKERS] pg_dump.options.diff
Re: [HACKERS] pg_dump.options.diff
----- Original Message -----
From: "Tom Lane"
Sent: January 02, 2003 3:20 PM
> > #if defined(HAVE_GETOPT_LONG)
> > #define xo(long,short,desc) printf("%s %s\n", long, desc)
> > #else
> > #define xo(long,short,desc) printf("%s %s\n", short, desc)
> > #endif
>
> > seems relatively generic, so it could be used by more than one tool.
>
> But there's no good place to put it. I'd say just stick it into each
> tool; it's no worse than repeating the existence of a "usage()"
> subroutine in each tool.
It ended up being in dumputils.h
Attached a patch for pg_dump(all) and pg_restore eliminating dupes
in option descriptions as per above xo "technology".
Please review and apply if there are no too many objections.
thank you,
-s
Re: [HACKERS] pg_dump.options.diff
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Serguei Mokhov" writes:
>> But there's no good place to put it. I'd say just stick it into each
>> tool; it's no worse than repeating the existence of a "usage()"
>> subroutine in each tool.
> It ended up being in dumputils.h
I really don't like putting a macro with a name as short as "xo" into a
header file, even one of relatively narrow scope. It's too likely to
create weird conflicts. My inclination is to make the coding be more
like
static void
usage(void)
{
#if defined(HAVE_GETOPT_LONG)
#define xo(longOption,shortOption,desc) printf("%s %s\n", longOption, desc)
#else
#define xo(longOption,shortOption,desc) printf("%s %s\n", shortOption, desc)
#endif
... lots of xo() calls ...
#undef xo
}
This gives us the convenience of a very short name within the usage()
subroutines, while not polluting the namespace for everyplace else in
these utilities.
As I said before, duplicating the definition of xo() in each file that
uses it doesn't bother me a bit; it's too simple for that to be a
significant objection.
regards, tom lane