diff options
| author | Tom Lane | 2014-02-15 19:31:30 +0000 |
|---|---|---|
| committer | Tom Lane | 2014-02-15 19:31:30 +0000 |
| commit | 60ff2fdd9970ba29f5267317a5e7354d2658c1e5 (patch) | |
| tree | 1bf03f09220a25a87f2a3bbfda5391a722d83541 /contrib | |
| parent | 32be1c8e900b89a89ec5e3a064c6b6010869d062 (diff) | |
Centralize getopt-related declarations in a new header file pg_getopt.h.
We used to have externs for getopt() and its API variables scattered
all over the place. Now that we find we're going to need to tweak the
variable declarations for Cygwin, it seems like a good idea to have
just one place to tweak.
In this commit, the variables are declared "#ifndef HAVE_GETOPT_H".
That may or may not work everywhere, but we'll soon find out.
Andres Freund
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/oid2name/oid2name.c | 8 | ||||
| -rw-r--r-- | contrib/pg_archivecleanup/pg_archivecleanup.c | 13 | ||||
| -rw-r--r-- | contrib/pg_standby/pg_standby.c | 13 | ||||
| -rw-r--r-- | contrib/pg_upgrade/option.c | 2 | ||||
| -rw-r--r-- | contrib/pgbench/pgbench.c | 8 | ||||
| -rw-r--r-- | contrib/vacuumlo/vacuumlo.c | 5 |
6 files changed, 5 insertions, 44 deletions
diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c index 67d79346b22..d8565941f90 100644 --- a/contrib/oid2name/oid2name.c +++ b/contrib/oid2name/oid2name.c @@ -9,14 +9,8 @@ */ #include "postgres_fe.h" -#include <unistd.h> -#ifdef HAVE_GETOPT_H -#include <getopt.h> -#endif - -extern char *optarg; - #include "libpq-fe.h" +#include "pg_getopt.h" /* an extensible array to keep track of elements to show */ typedef struct diff --git a/contrib/pg_archivecleanup/pg_archivecleanup.c b/contrib/pg_archivecleanup/pg_archivecleanup.c index f12331a62ec..7b5484bb6ac 100644 --- a/contrib/pg_archivecleanup/pg_archivecleanup.c +++ b/contrib/pg_archivecleanup/pg_archivecleanup.c @@ -17,20 +17,9 @@ #include <sys/stat.h> #include <fcntl.h> #include <signal.h> - -#ifndef WIN32 #include <sys/time.h> -#include <unistd.h> - -#ifdef HAVE_GETOPT_H -#include <getopt.h> -#endif -#else /* WIN32 */ -extern int getopt(int argc, char *const argv[], const char *optstring); -#endif /* ! WIN32 */ -extern char *optarg; -extern int optind; +#include "pg_getopt.h" const char *progname; diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c index 059c8205279..144edd8a072 100644 --- a/contrib/pg_standby/pg_standby.c +++ b/contrib/pg_standby/pg_standby.c @@ -28,20 +28,9 @@ #include <sys/stat.h> #include <fcntl.h> #include <signal.h> - -#ifdef WIN32 -int getopt(int argc, char *const argv[], const char *optstring); -#else #include <sys/time.h> -#include <unistd.h> - -#ifdef HAVE_GETOPT_H -#include <getopt.h> -#endif -#endif /* ! WIN32 */ -extern char *optarg; -extern int optind; +#include "pg_getopt.h" const char *progname; diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c index 4c08e94ffd0..cd9f66dd117 100644 --- a/contrib/pg_upgrade/option.c +++ b/contrib/pg_upgrade/option.c @@ -10,10 +10,10 @@ #include "postgres_fe.h" #include "miscadmin.h" +#include "getopt_long.h" #include "pg_upgrade.h" -#include <getopt_long.h> #include <time.h> #include <sys/types.h> #include <sys/stat.h> diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 16b7ab5ddc7..a836acfae98 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -40,12 +40,7 @@ #include <ctype.h> #include <math.h> #include <signal.h> - -#ifndef WIN32 #include <sys/time.h> -#include <unistd.h> -#endif /* ! WIN32 */ - #ifdef HAVE_SYS_SELECT_H #include <sys/select.h> #endif @@ -89,9 +84,6 @@ static int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start static int pthread_join(pthread_t th, void **thread_return); #endif -extern char *optarg; -extern int optind; - /******************************************************************** * some configurable parameters */ diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c index 3981dd6260f..c2e5bad438b 100644 --- a/contrib/vacuumlo/vacuumlo.c +++ b/contrib/vacuumlo/vacuumlo.c @@ -22,15 +22,12 @@ #endif #include "libpq-fe.h" +#include "pg_getopt.h" #define atooid(x) ((Oid) strtoul((x), NULL, 10)) #define BUFSIZE 1024 -extern char *optarg; -extern int optind, - opterr; - enum trivalue { TRI_DEFAULT, |
