From 1d26226d9583ad7bee290ca9bba1aa3794e98a53 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 4 Apr 2009 21:55:50 +0000 Subject: Make an attempt at fixing our current Solaris 11 breakage: add a configure probe for opterr (exactly like the one for optreset) and have getopt.c define the variables only if configure doesn't find them in libc. --- src/include/pg_config.h.in | 3 +++ src/port/getopt.c | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 3cc7c7ce6a8..34732278277 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -221,6 +221,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the global variable 'int opterr'. */ +#undef HAVE_INT_OPTERR + /* Define to 1 if you have the global variable 'int optreset'. */ #undef HAVE_INT_OPTRESET diff --git a/src/port/getopt.c b/src/port/getopt.c index 796a009dfa7..2cc2519116f 100644 --- a/src/port/getopt.c +++ b/src/port/getopt.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/port/getopt.c,v 1.11 2007/03/26 21:44:11 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/port/getopt.c,v 1.12 2009/04/04 21:55:50 tgl Exp $ */ /* This is used by psql under Win32 */ @@ -37,12 +37,25 @@ static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; #endif /* LIBC_SCCS and not lint */ +/* + * On some versions of Solaris, opterr and friends are defined in core libc + * rather than in a separate getopt module. Define these variables only + * if configure found they aren't there by default. (We assume that testing + * opterr is sufficient for all of these except optreset.) + */ +#ifndef HAVE_INT_OPTERR + int opterr = 1, /* if error message should be printed */ optind = 1, /* index into parent argv vector */ - optopt, /* character checked for validity */ - optreset; /* reset getopt */ + optopt; /* character checked for validity */ char *optarg; /* argument associated with option */ +#endif + +#ifndef HAVE_INT_OPTRESET +int optreset; /* reset getopt */ +#endif + #define BADCH (int)'?' #define BADARG (int)':' #define EMSG "" -- cgit v1.2.3