mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Move our own getopt() implementation to _PyOS_GetOpt(), and use it
regardless of whether the system getopt() does what we want. This avoids the hassle with prototypes and externs, and the check to see if the system getopt() does what we want. Prefix optind, optarg and opterr with _PyOS_ to avoid name clashes. Add new include file to define the right symbols. Fix Demo/pyserv/pyserv.c to include getopt.h itself, instead of relying on Python to provide it.
This commit is contained in:
parent
9dce7b3737
commit
2cffc7d420
7 changed files with 73 additions and 130 deletions
86
configure
vendored
86
configure
vendored
|
@ -4839,7 +4839,7 @@ else
|
|||
int main() {
|
||||
|
||||
/* Ultrix mips cc rejects this. */
|
||||
typedef int charset[2]; const charset x;
|
||||
typedef int charset[2]; const charset x = {0,0};
|
||||
/* SunOS 4.1.1 cc rejects this. */
|
||||
char const *const *ccp;
|
||||
char **p;
|
||||
|
@ -4914,7 +4914,7 @@ for ac_kw in inline __inline__ __inline; do
|
|||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
} $ac_kw foo() {
|
||||
} int $ac_kw foo() {
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:4921: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
|
@ -5625,47 +5625,9 @@ done
|
|||
|
||||
LIBS=$LIBS_SAVE
|
||||
|
||||
# check for getopt
|
||||
echo $ac_n "checking for genuine getopt""... $ac_c" 1>&6
|
||||
echo "configure:5631: checking for genuine getopt" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_func_getopt'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then
|
||||
ac_cv_func_getopt=no
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 5639 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
extern int optind, opterr, getopt();
|
||||
extern char* optarg;
|
||||
int main() {
|
||||
char* av[] = { "testprog", "parameter", "-fFlag", NULL };
|
||||
opterr = 0;
|
||||
if (getopt(3, av, "f:") == 'f') { exit(1); }
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:5651: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_func_getopt=yes
|
||||
else
|
||||
echo "configure: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
rm -fr conftest*
|
||||
ac_cv_func_getopt=no
|
||||
fi
|
||||
rm -fr conftest*
|
||||
fi
|
||||
|
||||
fi
|
||||
echo "$ac_t""$ac_cv_func_getopt" 1>&6
|
||||
test $ac_cv_func_getopt = no && LIBOBJS="$LIBOBJS getopt.o"
|
||||
|
||||
# check whether malloc(0) returns NULL or not
|
||||
echo $ac_n "checking what malloc(0) returns""... $ac_c" 1>&6
|
||||
echo "configure:5669: checking what malloc(0) returns" >&5
|
||||
echo "configure:5631: checking what malloc(0) returns" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_malloc_zero'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -5673,7 +5635,7 @@ else
|
|||
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 5677 "configure"
|
||||
#line 5639 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB
|
||||
|
@ -5692,7 +5654,7 @@ main() {
|
|||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:5696: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:5658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_malloc_zero=nonnull
|
||||
else
|
||||
|
@ -5718,17 +5680,17 @@ fi
|
|||
# check for wchar.h
|
||||
ac_safe=`echo "wchar.h" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for wchar.h""... $ac_c" 1>&6
|
||||
echo "configure:5722: checking for wchar.h" >&5
|
||||
echo "configure:5684: checking for wchar.h" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 5727 "configure"
|
||||
#line 5689 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <wchar.h>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:5732: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:5694: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
|
@ -5758,12 +5720,12 @@ fi
|
|||
# check for usable wchar_t
|
||||
usable_wchar_t="unkown"
|
||||
echo $ac_n "checking for usable wchar_t""... $ac_c" 1>&6
|
||||
echo "configure:5762: checking for usable wchar_t" >&5
|
||||
echo "configure:5724: checking for usable wchar_t" >&5
|
||||
if test "$cross_compiling" = yes; then
|
||||
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 5767 "configure"
|
||||
#line 5729 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#include "wchar.h"
|
||||
|
@ -5777,7 +5739,7 @@ main() {
|
|||
}
|
||||
|
||||
EOF
|
||||
if { (eval echo configure:5781: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:5743: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define HAVE_USABLE_WCHAR_T 1
|
||||
|
@ -5796,14 +5758,14 @@ echo "$ac_t""$usable_wchar_t" 1>&6
|
|||
|
||||
# check for endianness
|
||||
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
|
||||
echo "configure:5800: checking whether byte ordering is bigendian" >&5
|
||||
echo "configure:5762: checking whether byte ordering is bigendian" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
ac_cv_c_bigendian=unknown
|
||||
# See if sys/param.h defines the BYTE_ORDER macro.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 5807 "configure"
|
||||
#line 5769 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -5814,11 +5776,11 @@ int main() {
|
|||
#endif
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:5818: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:5780: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
# It does; now see whether it defined to BIG_ENDIAN or not.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 5822 "configure"
|
||||
#line 5784 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -5829,7 +5791,7 @@ int main() {
|
|||
#endif
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:5833: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:5795: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_c_bigendian=yes
|
||||
else
|
||||
|
@ -5849,7 +5811,7 @@ if test "$cross_compiling" = yes; then
|
|||
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 5853 "configure"
|
||||
#line 5815 "configure"
|
||||
#include "confdefs.h"
|
||||
main () {
|
||||
/* Are we little or big endian? From Harbison&Steele. */
|
||||
|
@ -5862,7 +5824,7 @@ main () {
|
|||
exit (u.c[sizeof (long) - 1] == 1);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:5866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:5828: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_c_bigendian=no
|
||||
else
|
||||
|
@ -5889,7 +5851,7 @@ fi
|
|||
# Check whether right shifting a negative integer extends the sign bit
|
||||
# or fills with zeros (like the Cray J90, according to Tim Peters).
|
||||
echo $ac_n "checking whether right shift extends the sign bit""... $ac_c" 1>&6
|
||||
echo "configure:5893: checking whether right shift extends the sign bit" >&5
|
||||
echo "configure:5855: checking whether right shift extends the sign bit" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_rshift_extends_sign'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -5898,7 +5860,7 @@ if test "$cross_compiling" = yes; then
|
|||
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 5902 "configure"
|
||||
#line 5864 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main()
|
||||
|
@ -5907,7 +5869,7 @@ int main()
|
|||
}
|
||||
|
||||
EOF
|
||||
if { (eval echo configure:5911: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:5873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_rshift_extends_sign=yes
|
||||
else
|
||||
|
@ -5939,12 +5901,12 @@ cat >> confdefs.h <<\EOF
|
|||
#endif
|
||||
EOF
|
||||
echo $ac_n "checking for socklen_t""... $ac_c" 1>&6
|
||||
echo "configure:5943: checking for socklen_t" >&5
|
||||
echo "configure:5905: checking for socklen_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 5948 "configure"
|
||||
#line 5910 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
|
@ -5973,7 +5935,7 @@ fi
|
|||
|
||||
|
||||
echo $ac_n "checking for Modules/Setup""... $ac_c" 1>&6
|
||||
echo "configure:5977: checking for Modules/Setup" >&5
|
||||
echo "configure:5939: checking for Modules/Setup" >&5
|
||||
if test ! -f Modules/Setup ; then
|
||||
if test ! -d Modules ; then
|
||||
mkdir Modules
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue