Skip to content

Commit 1d26226

Browse files
committed
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.
1 parent 090173a commit 1d26226

File tree

4 files changed

+88
-4
lines changed

4 files changed

+88
-4
lines changed

configure

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18655,6 +18655,65 @@ fi
1865518655
fi
1865618656

1865718657

18658+
{ echo "$as_me:$LINENO: checking for opterr" >&5
18659+
echo $ECHO_N "checking for opterr... $ECHO_C" >&6; }
18660+
if test "${pgac_cv_var_int_opterr+set}" = set; then
18661+
echo $ECHO_N "(cached) $ECHO_C" >&6
18662+
else
18663+
cat >conftest.$ac_ext <<_ACEOF
18664+
/* confdefs.h. */
18665+
_ACEOF
18666+
cat confdefs.h >>conftest.$ac_ext
18667+
cat >>conftest.$ac_ext <<_ACEOF
18668+
/* end confdefs.h. */
18669+
#include <unistd.h>
18670+
int
18671+
main ()
18672+
{
18673+
extern int opterr; opterr = 1;
18674+
;
18675+
return 0;
18676+
}
18677+
_ACEOF
18678+
rm -f conftest.$ac_objext conftest$ac_exeext
18679+
if { (ac_try="$ac_link"
18680+
case "(($ac_try" in
18681+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18682+
*) ac_try_echo=$ac_try;;
18683+
esac
18684+
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
18685+
(eval "$ac_link") 2>conftest.er1
18686+
ac_status=$?
18687+
grep -v '^ *+' conftest.er1 >conftest.err
18688+
rm -f conftest.er1
18689+
cat conftest.err >&5
18690+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
18691+
(exit $ac_status); } && {
18692+
test -z "$ac_c_werror_flag" ||
18693+
test ! -s conftest.err
18694+
} && test -s conftest$ac_exeext &&
18695+
$as_test_x conftest$ac_exeext; then
18696+
pgac_cv_var_int_opterr=yes
18697+
else
18698+
echo "$as_me: failed program was:" >&5
18699+
sed 's/^/| /' conftest.$ac_ext >&5
18700+
18701+
pgac_cv_var_int_opterr=no
18702+
fi
18703+
18704+
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
18705+
conftest$ac_exeext conftest.$ac_ext
18706+
fi
18707+
{ echo "$as_me:$LINENO: result: $pgac_cv_var_int_opterr" >&5
18708+
echo "${ECHO_T}$pgac_cv_var_int_opterr" >&6; }
18709+
if test x"$pgac_cv_var_int_opterr" = x"yes"; then
18710+
18711+
cat >>confdefs.h <<\_ACEOF
18712+
#define HAVE_INT_OPTERR 1
18713+
_ACEOF
18714+
18715+
fi
18716+
1865818717
{ echo "$as_me:$LINENO: checking for optreset" >&5
1865918718
echo $ECHO_N "checking for optreset... $ECHO_C" >&6; }
1866018719
if test "${pgac_cv_var_int_optreset+set}" = set; then

configure.in

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.592 2009/03/27 19:58:11 tgl Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.593 2009/04/04 21:55:50 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1317,6 +1317,15 @@ AC_CHECK_FUNC(syslog,
13171317
[AC_CHECK_HEADER(syslog.h,
13181318
[AC_DEFINE(HAVE_SYSLOG, 1, [Define to 1 if you have the syslog interface.])])])
13191319

1320+
AC_CACHE_CHECK([for opterr], pgac_cv_var_int_opterr,
1321+
[AC_TRY_LINK([#include <unistd.h>],
1322+
[extern int opterr; opterr = 1;],
1323+
[pgac_cv_var_int_opterr=yes],
1324+
[pgac_cv_var_int_opterr=no])])
1325+
if test x"$pgac_cv_var_int_opterr" = x"yes"; then
1326+
AC_DEFINE(HAVE_INT_OPTERR, 1, [Define to 1 if you have the global variable 'int opterr'.])
1327+
fi
1328+
13201329
AC_CACHE_CHECK([for optreset], pgac_cv_var_int_optreset,
13211330
[AC_TRY_LINK([#include <unistd.h>],
13221331
[extern int optreset; optreset = 1;],

src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@
221221
/* Define to 1 if you have the <inttypes.h> header file. */
222222
#undef HAVE_INTTYPES_H
223223

224+
/* Define to 1 if you have the global variable 'int opterr'. */
225+
#undef HAVE_INT_OPTERR
226+
224227
/* Define to 1 if you have the global variable 'int optreset'. */
225228
#undef HAVE_INT_OPTRESET
226229

src/port/getopt.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/port/getopt.c,v 1.11 2007/03/26 21:44:11 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/port/getopt.c,v 1.12 2009/04/04 21:55:50 tgl Exp $ */
22

33
/* This is used by psql under Win32 */
44

@@ -37,12 +37,25 @@ static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
3737
#endif /* LIBC_SCCS and not lint */
3838

3939

40+
/*
41+
* On some versions of Solaris, opterr and friends are defined in core libc
42+
* rather than in a separate getopt module. Define these variables only
43+
* if configure found they aren't there by default. (We assume that testing
44+
* opterr is sufficient for all of these except optreset.)
45+
*/
46+
#ifndef HAVE_INT_OPTERR
47+
4048
int opterr = 1, /* if error message should be printed */
4149
optind = 1, /* index into parent argv vector */
42-
optopt, /* character checked for validity */
43-
optreset; /* reset getopt */
50+
optopt; /* character checked for validity */
4451
char *optarg; /* argument associated with option */
4552

53+
#endif
54+
55+
#ifndef HAVE_INT_OPTRESET
56+
int optreset; /* reset getopt */
57+
#endif
58+
4659
#define BADCH (int)'?'
4760
#define BADARG (int)':'
4861
#define EMSG ""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy