pg_resetxlog options

Started by Andrew Dunstanabout 21 years ago6 messages
#1Andrew Dunstan
andrew@dunslane.net

Why does pg_resetxlog seem top be the only one of our programs that has
no long form options (or at least the only one that calls getopt rather
than getopt_long)? Should we make it consistent with everything else?

I noticed this when examining a compile warning about implicit
declaration of getopt().

cheers

andrew

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#1)
Re: pg_resetxlog options

Andrew Dunstan <andrew@dunslane.net> writes:

Why does pg_resetxlog seem top be the only one of our programs that has
no long form options (or at least the only one that calls getopt rather
than getopt_long)? Should we make it consistent with everything else?

I think just laziness on my part when I first wrote it --- it only had
one or two options anyway, and didn't seem to need long options. But if
converting to getopt_long is the easy way to avoid a porting problem,
do it.

regards, tom lane

#3Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#2)
1 attachment(s)
Re: pg_resetxlog options

Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

Why does pg_resetxlog seem top be the only one of our programs that has
no long form options (or at least the only one that calls getopt rather
than getopt_long)? Should we make it consistent with everything else?

I think just laziness on my part when I first wrote it --- it only had
one or two options anyway, and didn't seem to need long options. But if
converting to getopt_long is the easy way to avoid a porting problem,
do it.

Some other time maybe. Meanwhile, this patch ought to make it compile
more cleanly on Windows - not sure why I get errors there but not Linux.

cheers

andrew

Attachments:

resetxlog.patchtext/x-patch; name=resetxlog.patchDownload
Index: src/bin/pg_resetxlog/pg_resetxlog.c
===================================================================
RCS file: /home/cvsmirror/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v
retrieving revision 1.24
diff -c -r1.24 pg_resetxlog.c
*** src/bin/pg_resetxlog/pg_resetxlog.c	29 Aug 2004 16:34:48 -0000	1.24
--- src/bin/pg_resetxlog/pg_resetxlog.c	17 Nov 2004 20:24:43 -0000
***************
*** 36,41 ****
--- 36,45 ----
  #include <sys/time.h>
  #include <time.h>
  #include <unistd.h>
+ #ifdef HAVE_GETOPT_H
+ #include <getopt.h>
+ #endif
+ 
  
  #include "access/xlog.h"
  #include "access/xlog_internal.h"
#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#3)
Re: pg_resetxlog options

Andrew Dunstan <andrew@dunslane.net> writes:

Some other time maybe. Meanwhile, this patch ought to make it compile
more cleanly on Windows - not sure why I get errors there but not
Linux.

The Single Unix Spec says that getopt() is supposed to be defined by
<unistd.h>, but I guess reading the spec closely is not a hobby in
Redmond...

Patch applied.

regards, tom lane

#5Peter Eisentraut
peter_e@gmx.net
In reply to: Andrew Dunstan (#3)
Re: pg_resetxlog options

Andrew Dunstan wrote:

Some other time maybe. Meanwhile, this patch ought to make it compile
more cleanly on Windows - not sure why I get errors there but not
Linux.

Because getopt() is normally declared in unistd.h, not getopt.h (Windows
being an exception?).

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#6Zeugswetter Andreas DAZ SD
ZeugswetterA@spardat.at
In reply to: Peter Eisentraut (#5)
Re: pg_resetxlog options

Some other time maybe. Meanwhile, this patch ought to make it compile
more cleanly on Windows - not sure why I get errors there but not
Linux.

Because getopt() is normally declared in unistd.h, not getopt.h (Windows
being an exception?).

getopt is not in any standard Windows headers. The getopt.h header is from mingw
to assist porting (don't know why they didn't put it in unistd.h ?).

Andreas