Skip to content

Commit

Permalink
Clean up nbcompat handling.
Browse files Browse the repository at this point in the history
We shouldn't test for nbcompat headers or library ourselves, pkgsrc
handles pulling it in and setting variables as appropriate depending on
the host system.

Instead, include nbcompat only when in use, otherwise attempt to include
native headers.

At some point it would be nice to ditch nbcompat completely and just
have our own compatibility functions to have a clearer idea of where we
diverge from the standards, and try to reduce where possible.
  • Loading branch information
Jonathan Perkin committed May 24, 2020
1 parent 219c657 commit a620e4f
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 118 deletions.
12 changes: 0 additions & 12 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
/* Define to 1 if you have the <bsd/libutil.h> header file. */
#undef HAVE_BSD_LIBUTIL_H

/* Define to 1 if you have the <err.h> header file. */
#undef HAVE_ERR_H

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

Expand All @@ -15,12 +12,6 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define to 1 if you have the <nbcompat.h> header file. */
#undef HAVE_NBCOMPAT_H

/* Define to 1 if you have the <nbcompat/string.h> header file. */
#undef HAVE_NBCOMPAT_STRING_H

/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

Expand Down Expand Up @@ -48,9 +39,6 @@
/* Define to 1 if `st_umtime' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_UMTIME

/* Define to 1 if you have the <sys/queue.h> header file. */
#undef HAVE_SYS_QUEUE_H

/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H

Expand Down
67 changes: 0 additions & 67 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -3571,32 +3571,6 @@ fi
done


for ac_header in err.h sys/queue.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF

fi

done

for ac_header in nbcompat.h nbcompat/string.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF

fi

done

for ac_header in util.h bsd/libutil.h libutil.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
Expand Down Expand Up @@ -3796,47 +3770,6 @@ else
as_fn_error $? "libfetch not found." "$LINENO" 5
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strlcpy in -lnbcompat" >&5
$as_echo_n "checking for strlcpy in -lnbcompat... " >&6; }
if ${ac_cv_lib_nbcompat_strlcpy+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnbcompat $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char strlcpy ();
int
main ()
{
return strlcpy ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_nbcompat_strlcpy=yes
else
ac_cv_lib_nbcompat_strlcpy=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nbcompat_strlcpy" >&5
$as_echo "$ac_cv_lib_nbcompat_strlcpy" >&6; }
if test "x$ac_cv_lib_nbcompat_strlcpy" = xyes; then :
LIBS="$LIBS -lnbcompat"

fi




Expand Down
5 changes: 0 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ AC_CHECK_FUNC([humanize_number],,
[SRCS="humanize_number.c $SRCS"]
)]
)
AC_CHECK_HEADERS([err.h sys/queue.h])
AC_CHECK_HEADERS([nbcompat.h nbcompat/string.h])
AC_CHECK_HEADERS([util.h bsd/libutil.h libutil.h])
AC_CHECK_HEADERS([sys/termios.h termios.h])
#
Expand All @@ -55,9 +53,6 @@ AC_SEARCH_LIBS([inet_addr], [nsl])
AC_SEARCH_LIBS([fetchGetURL], [fetch],,
[AC_MSG_ERROR(libfetch not found.)],
)
AC_CHECK_LIB([nbcompat], [strlcpy],
[LIBS="$LIBS -lnbcompat"]
)

AC_SUBST(SRCS)

Expand Down
19 changes: 7 additions & 12 deletions external/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@

#include "config.h"

#if HAVE_NBCOMPAT_H
#include <nbcompat.h>
#else
#include <err.h>
#include <sys/queue.h>
#endif

#include <assert.h>
#include <ctype.h>
#include <dirent.h>
Expand All @@ -45,18 +52,6 @@
#include <sys/stat.h>
#include <sys/wait.h>

#if HAVE_ERR_H
#include <err.h>
#endif

#if HAVE_NBCOMPAT_H
#include <nbcompat.h>
#endif

#if HAVE_SYS_QUEUE_H
#include <sys/queue.h>
#endif

/* Macros */
#ifndef __UNCONST
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
Expand Down
3 changes: 1 addition & 2 deletions external/progressmeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if HAVE_CONFIG_H
#include "config.h"
#endif

#if HAVE_NBCOMPAT_H
#include <nbcompat.h>
#endif
Expand Down
8 changes: 5 additions & 3 deletions pkgin.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
#ifndef _PKGIN_H
#define _PKGIN_H

#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_SYS_QUEUE_H

#ifdef HAVE_NBCOMPAT_H
#include <nbcompat.h>
#else
#include <err.h>
#include <sys/queue.h>
#endif

Expand Down
1 change: 0 additions & 1 deletion summary.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* Import pkg_summary to SQLite database
*/

#include "tools.h"
#include "pkgin.h"

static const struct Summary {
Expand Down
17 changes: 1 addition & 16 deletions tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,24 @@

#include "config.h"

#if HAVE_NBCOMPAT_H
#include <nbcompat.h>
#endif

#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include <unistd.h>
#include <stdlib.h>

#include <sys/stat.h>
#include <sys/utsname.h>

#if HAVE_NBCOMPAT_STRING_H /* strsep() */
#include <nbcompat/string.h>
#else
#include <string.h>
#endif

#if HAVE_ERR_H
#include <err.h>
#endif

#if defined(HAVE_BSD_LIBUTIL_H)
#include <bsd/libutil.h>
#elif defined(HAVE_LIBUTIL_H)
#include <libutil.h>
#elif defined(HAVE_UTIL_H)
#include <util.h>
#else
#include <nbcompat/util.h>
#endif

#include "external/lib.h"
Expand Down

0 comments on commit a620e4f

Please sign in to comment.