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

Commit139e427

Browse files
committed
Use our own getopt() on OpenBSD.
Recent OpenBSD (at least 5.9 and up) has a version of getopt(3)that will not cope with the "-:" spec we use to accept double-dashoptions in postgres.c and postmaster.c. Admittedly, that's a hackbecause POSIX only requires getopt() to allow alphanumeric optioncharacters. I have no desire to find another way, however, solet's just do what we were already doing on Solaris: force useof our own src/port/getopt.c implementation.In passing, improve some of the comments around said implementation.Per buildfarm and local testing. Back-patch to all supported branches.Discussion:https://postgr.es/m/30197.1547835700@sss.pgh.pa.us
1 parent08b5328 commit139e427

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

‎configure‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13881,9 +13881,9 @@ esac
1388113881

1388213882
fi
1388313883

13884-
# Solaris' getopt() doesn't do what we want for long options, so always use
13885-
# our version onthat platform.
13886-
iftest"$PORTNAME" ="solaris";then
13884+
#On OpenBSD andSolaris, getopt() doesn't do what we want for long options
13885+
#(i.e., allow '-' as a flag character), so useour version onthose platforms.
13886+
iftest"$PORTNAME" ="openbsd" -o"$PORTNAME" ="solaris";then
1388713887
case"$LIBOBJS"in
1388813888
*" getopt.$ac_objext"* ) ;;
1388913889
*) LIBOBJS="$LIBOBJS getopt.$ac_objext"

‎configure.in‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,9 +1625,9 @@ else
16251625
AC_LIBOBJ(getopt_long)
16261626
fi
16271627

1628-
# Solaris' getopt() doesn't do what we want for long options, so always use
1629-
# our version onthat platform.
1630-
if test "$PORTNAME" = "solaris"; then
1628+
#On OpenBSD andSolaris, getopt() doesn't do what we want for long options
1629+
#(i.e., allow '-' as a flag character), so useour version onthose platforms.
1630+
if test "$PORTNAME" = "openbsd" -o "$PORTNAME" = "solaris"; then
16311631
AC_LIBOBJ(getopt)
16321632
fi
16331633

‎src/include/pg_getopt.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
/*
2+
* Postgres files that use getopt(3) always include this file.
3+
* We must cope with three different scenarios:
4+
* 1. We're using the platform's getopt(), and we should just import the
5+
* appropriate declarations.
6+
* 2. The platform lacks getopt(), and we must declare everything.
7+
* 3. The platform has getopt(), but we're not using it because we don't
8+
* like its behavior. The declarations we make here must be compatible
9+
* with both the platform's getopt() and our src/port/getopt.c.
10+
*
211
* Portions Copyright (c) 1987, 1993, 1994
312
* The Regents of the University of California. All rights reserved.
413
*
@@ -39,6 +48,7 @@ extern intoptopt;
3948
externintoptreset;
4049
#endif
4150

51+
/* Provide getopt() declaration if the platform doesn't have it */
4252
#ifndefHAVE_GETOPT
4353
externintgetopt(intnargc,char*const*nargv,constchar*ostr);
4454
#endif

‎src/port/getopt.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* src/port/getopt.c */
22

3-
/* This is used by psql under Win32 */
4-
53
/*
64
* Copyright (c) 1987, 1993, 1994
75
*The Regents of the University of California. All rights reserved.
@@ -40,10 +38,11 @@ static char sccsid[] = "@(#)getopt.c8.3 (Berkeley) 4/27/95";
4038

4139

4240
/*
43-
* On some versions of Solaris, opterr and friends are defined in core libc
44-
* rather than in a separate getopt module. Define these variables only
45-
* if configure found they aren't there by default. (We assume that testing
46-
* opterr is sufficient for all of these.)
41+
* On OpenBSD and some versions of Solaris, opterr and friends are defined in
42+
* core libc rather than in a separate getopt module. Define these variables
43+
* only if configure found they aren't there by default; otherwise, this
44+
* module and its callers will just use libc's variables. (We assume that
45+
* testing opterr is sufficient for all of these.)
4746
*/
4847
#ifndefHAVE_INT_OPTERR
4948

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp