On 12/15/2010 12:28 PM, Andrew Dunstan wrote:



I think you're probably right. narwhal reports having optreset, but my Mingw reports not having it, so this looks like a likely culprit.


And the attached hack allowed "make check" to succeed.

I think the logic in tcop/postgres.c and postmaster/postmaster.c is probably wrong. If we are using our getopt/getopt_long, we want to be setting optreset, whether or not configure found one in the system libraries.

cheers

andrew



diff --git a/configure b/configure
index 08fd1c8..0cfcb9a 100755
--- a/configure
+++ b/configure
@@ -20758,6 +20758,11 @@ esac
 
 fi
 
+if test "$PORTNAME" = "win32" -a x"$pgac_cv_var_int_optreset" != x"yes"; then 
+  LIBOBJS="$LIBOBJS getopt.$ac_objext getopt_long.$ac_objext"
+fi
+
+
 # Cygwin's erand48() is broken (always returns zero) in some releases,
 # so force use of ours.
 if test "$PORTNAME" = "cygwin"; then
diff --git a/src/backend/postmaster/postmaster.c 
b/src/backend/postmaster/postmaster.c
index 90854f4..c2f0436 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -313,9 +313,7 @@ extern char *optarg;
 extern int     optind,
                        opterr;
 
-#ifdef HAVE_INT_OPTRESET
 extern int     optreset;                       /* might not be declared by 
system headers */
-#endif
 
 #ifdef USE_BONJOUR
 static DNSServiceRef bonjour_sdref = NULL;
@@ -751,9 +749,7 @@ PostmasterMain(int argc, char *argv[])
         * getopt(3) library so that it will work correctly in subprocesses.
         */
        optind = 1;
-#ifdef HAVE_INT_OPTRESET
        optreset = 1;                           /* some systems need this too */
-#endif
 
        /* For debugging: display postmaster environment */
        {
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index ff2e9bd..da7db16 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -78,9 +78,7 @@
 extern char *optarg;
 extern int     optind;
 
-#ifdef HAVE_INT_OPTRESET
 extern int     optreset;                       /* might not be declared by 
system headers */
-#endif
 
 
 /* ----------------
@@ -3442,9 +3440,7 @@ process_postgres_switches(int argc, char *argv[], 
GucContext ctx)
         * or when this function is called a second time with another array.
         */
        optind = 1;
-#ifdef HAVE_INT_OPTRESET
        optreset = 1;                           /* some systems need this too */
-#endif
 
        return dbname;
 }
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to