commit - 0e5a098ac4b42e007819f387dac06a941534cea5
commit + 62f363ce7bf30bd7855ef9d7a54628f64322926e
blob - 7e6b79ae62757d1c015a7205088eafd1ddfbfaa0
blob + 18a7820985a416bc26a0f3cf0e29f47841b18123
--- compat/Makefile.am
+++ compat/Makefile.am
fmt_scaled.c \
freezero.c \
getdtablecount.c \
- getopt.c \
getprogname.c \
merge.c \
reallocarray.c \
libopenbsd_compat_a_SOURCES += uuid.c bsd-poll.c bsd-poll.h
endif
+if !HAVE_GETOPT
+libopenbsd_compat_a_SOURCES += getopt.c
+endif
+
if !HAVE_B64
libopenbsd_compat_a_SOURCES += base64.c
LDADD += $(libresolv_LIBS)
blob - bc33cb31875dc69cb26099420531a03373eb1606
blob + 8fb5fec63f8b4d8c0162285ace7b93a93e74c436
--- compat/getopt.c
+++ compat/getopt.c
/* OPENBSD ORIGINAL: lib/libc/stdlib/getopt.c */
+#include "got_compat.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "got_compat.h"
-
int BSDopterr = 1, /* if error message should be printed */
BSDoptind = 1, /* index into parent argv vector */
BSDoptopt, /* character checked for validity */
blob - f77680096ad1835f084e287eb76deab4463f3a4e
blob + fb68b072a97da873e45ce9600c4f81815796c65d
--- configure.ac
+++ configure.ac
# Checks for header files.
AC_CHECK_HEADERS([ \
fcntl.h \
+ getopt.h \
langinfo.h \
libutil.h \
limits.h \
)
AM_CONDITIONAL([HAVE_SHA2], [test "x$ac_cv_header_sha2_h" = xyes])
+
+AC_CACHE_CHECK([whether getopt has optreset support],
+ ac_cv_have_getopt_optreset, [
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
+ [[ extern int optreset; optreset = 0; ]])],
+ [ ac_cv_have_getopt_optreset="yes" ],
+ [ ac_cv_have_getopt_optreset="no"
+ ])
+])
+AM_CONDITIONAL([HAVE_GETOPT], [test "x$ac_cv_have_getopt_optreset" = "xno"])
+if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
+ AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
+ [Define if your getopt(3) defines and uses optreset])
+fi
+
AC_CHECK_MEMBERS([struct pollfd.fd], [], [], [[
#include <sys/types.h>
#ifdef HAVE_POLL_H
blob - ec546e4b8d53c0c0e01752af08638c7ca5683bfd
blob + 68c02fe36df0f00abffe293ccae6d27b225b6297
--- include/got_compat2.h
+++ include/got_compat2.h
#define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
#endif
-#ifndef HAVE_LIBBSD
+#if !defined(HAVE_LIBBSD) && !defined(HAVE_GETOPT_OPTRESET)
/* getopt.c */
extern int BSDopterr;
extern int BSDoptind;