Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5cdd65f

Browse files
committed
Fix up getopt() reset management so it works on recent mingw.
The mingw people don't appear to care about compatibility with non-GNUversions of getopt, so force use of our own copy of getopt on Windows.Also, ensure that we make use of optreset when using our own copy.Per report from Andrew Dunstan. Back-patch to all versions supportedon Windows.
1 parent2a6ebe7 commit5cdd65f

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

‎configure

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20758,6 +20758,23 @@ esac
2075820758

2075920759
fi
2076020760

20761+
# mingw has adopted a GNU-centric interpretation of optind/optreset,
20762+
# so always use our version on Windows.
20763+
if test "$PORTNAME" = "win32"; then
20764+
case " $LIBOBJS " in
20765+
*" getopt.$ac_objext "* ) ;;
20766+
*) LIBOBJS="$LIBOBJS getopt.$ac_objext"
20767+
;;
20768+
esac
20769+
20770+
case " $LIBOBJS " in
20771+
*" getopt_long.$ac_objext "* ) ;;
20772+
*) LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
20773+
;;
20774+
esac
20775+
20776+
fi
20777+
2076120778
# Cygwin's erand48() is broken (always returns zero) in some releases,
2076220779
# so force use of ours.
2076320780
if test "$PORTNAME" = "cygwin"; then
@@ -20880,25 +20897,25 @@ fi
2088020897
done
2088120898

2088220899

20883-
case " $LIBOBJS " in
20900+
case " $LIBOBJS " in
2088420901
*" kill.$ac_objext "* ) ;;
2088520902
*) LIBOBJS="$LIBOBJS kill.$ac_objext"
2088620903
;;
2088720904
esac
2088820905

20889-
case " $LIBOBJS " in
20906+
case " $LIBOBJS " in
2089020907
*" open.$ac_objext "* ) ;;
2089120908
*) LIBOBJS="$LIBOBJS open.$ac_objext"
2089220909
;;
2089320910
esac
2089420911

20895-
case " $LIBOBJS " in
20912+
case " $LIBOBJS " in
2089620913
*" win32env.$ac_objext "* ) ;;
2089720914
*) LIBOBJS="$LIBOBJS win32env.$ac_objext"
2089820915
;;
2089920916
esac
2090020917

20901-
case " $LIBOBJS " in
20918+
case " $LIBOBJS " in
2090220919
*" win32error.$ac_objext "* ) ;;
2090320920
*) LIBOBJS="$LIBOBJS win32error.$ac_objext"
2090420921
;;

‎configure.in

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,13 @@ if test "$PORTNAME" = "solaris"; then
13281328
AC_LIBOBJ(getopt)
13291329
fi
13301330

1331+
# mingw has adopted a GNU-centric interpretation of optind/optreset,
1332+
# so always use our version on Windows.
1333+
if test "$PORTNAME" = "win32"; then
1334+
AC_LIBOBJ(getopt)
1335+
AC_LIBOBJ(getopt_long)
1336+
fi
1337+
13311338
# Cygwin's erand48() is broken (always returns zero) in some releases,
13321339
# so force use of ours.
13331340
if test "$PORTNAME" = "cygwin"; then
@@ -1336,13 +1343,13 @@ fi
13361343

13371344
# Win32 support
13381345
if test "$PORTNAME" = "win32"; then
1339-
AC_REPLACE_FUNCS(gettimeofday)
1340-
AC_LIBOBJ(kill)
1341-
AC_LIBOBJ(open)
1342-
AC_LIBOBJ(win32env)
1343-
AC_LIBOBJ(win32error)
1344-
AC_DEFINE([HAVE_SYMLINK], 1,
1345-
[Define to 1 if you have the `symlink' function.])
1346+
AC_REPLACE_FUNCS(gettimeofday)
1347+
AC_LIBOBJ(kill)
1348+
AC_LIBOBJ(open)
1349+
AC_LIBOBJ(win32env)
1350+
AC_LIBOBJ(win32error)
1351+
AC_DEFINE([HAVE_SYMLINK], 1,
1352+
[Define to 1 if you have the `symlink' function.])
13461353
fi
13471354

13481355
if test "$with_readline" = yes; then

‎src/backend/postmaster/postmaster.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ extern char *optarg;
313313
externintoptind,
314314
opterr;
315315

316-
#ifdefHAVE_INT_OPTRESET
316+
/* If not HAVE_GETOPT, we are using src/port/getopt.c, which has optreset */
317+
#if defined(HAVE_INT_OPTRESET)|| !defined(HAVE_GETOPT)
317318
externintoptreset;/* might not be declared by system headers */
318319
#endif
319320

@@ -751,7 +752,7 @@ PostmasterMain(int argc, char *argv[])
751752
* getopt(3) library so that it will work correctly in subprocesses.
752753
*/
753754
optind=1;
754-
#ifdefHAVE_INT_OPTRESET
755+
#if defined(HAVE_INT_OPTRESET)|| !defined(HAVE_GETOPT)
755756
optreset=1;/* some systems need this too */
756757
#endif
757758

‎src/backend/tcop/postgres.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
externchar*optarg;
7979
externintoptind;
8080

81-
#ifdefHAVE_INT_OPTRESET
81+
/* If not HAVE_GETOPT, we are using src/port/getopt.c, which has optreset */
82+
#if defined(HAVE_INT_OPTRESET)|| !defined(HAVE_GETOPT)
8283
externintoptreset;/* might not be declared by system headers */
8384
#endif
8485

@@ -3442,7 +3443,7 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx)
34423443
* or when this function is called a second time with another array.
34433444
*/
34443445
optind=1;
3445-
#ifdefHAVE_INT_OPTRESET
3446+
#if defined(HAVE_INT_OPTRESET)|| !defined(HAVE_GETOPT)
34463447
optreset=1;/* some systems need this too */
34473448
#endif
34483449

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp