pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/libnbcompat libnbcompat-20090322:
details: https://anonhg.NetBSD.org/pkgsrc/rev/74bccf6db490
branches: trunk
changeset: 556590:74bccf6db490
user: joerg <joerg%pkgsrc.org@localhost>
date: Sun Mar 22 22:33:13 2009 +0000
description:
libnbcompat-20090322:
Don't use getopt_long as replacement for getopt. It behaves different
and doesn't work well in combination with optreset. Instead use
getopt(3) from NetBSD if requested. Sync getopt_long.c with NetBSD while
here. Addresses issues with pkg_admin on Solaris reported by Tim Zingelman.
diffstat:
pkgtools/libnbcompat/Makefile | 4 +-
pkgtools/libnbcompat/files/configure | 32 ++---
pkgtools/libnbcompat/files/configure.ac | 18 +--
pkgtools/libnbcompat/files/getopt.c | 149 +++++++++++++++++++++++++++++++
pkgtools/libnbcompat/files/getopt_long.c | 96 +++++++++----------
5 files changed, 212 insertions(+), 87 deletions(-)
diffs (truncated from 509 to 300 lines):
diff -r 1fd577fa5d79 -r 74bccf6db490 pkgtools/libnbcompat/Makefile
--- a/pkgtools/libnbcompat/Makefile Sun Mar 22 22:31:46 2009 +0000
+++ b/pkgtools/libnbcompat/Makefile Sun Mar 22 22:33:13 2009 +0000
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.69 2009/03/02 13:54:55 joerg Exp $
+# $NetBSD: Makefile,v 1.70 2009/03/22 22:33:13 joerg Exp $
#
# NOTE: If you update this package, it is *mandatory* that you update
# pkgsrc/pkgtools/libnbcompat/files/README to reflect the actual
# list of tested and supported platforms.
#
-DISTNAME= libnbcompat-20090302
+DISTNAME= libnbcompat-20090322
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
diff -r 1fd577fa5d79 -r 74bccf6db490 pkgtools/libnbcompat/files/configure
--- a/pkgtools/libnbcompat/files/configure Sun Mar 22 22:31:46 2009 +0000
+++ b/pkgtools/libnbcompat/files/configure Sun Mar 22 22:33:13 2009 +0000
@@ -5910,7 +5910,6 @@
-pkg_use_nbcompat_getopt_long=yes
for ac_header in getopt.h
do
@@ -6112,9 +6111,14 @@
{ $as_echo "$as_me:$LINENO: result: $pkg_cv_have_struct_option" >&5
$as_echo "$pkg_cv_have_struct_option" >&6; }
if test "x$pkg_cv_have_struct_option" = "xyes"; then
- pkg_use_nbcompat_getopt_long=no
+ :
else
- pkg_use_nbcompat_getopt_long=yes
+ case " $LIBOBJS " in
+ *" getopt_long.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
+ ;;
+esac
+
:
fi
@@ -6126,25 +6130,15 @@
if test "$enable_bsd_getopt" = yes; then
if test "$ac_cv_have_decl_optreset" = no; then
- pkg_use_nbcompat_getopt_long=yes
+ case " $LIBOBJS " in
+ *" getopt.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS getopt.$ac_objext"
+ ;;
+esac
+
fi
fi
-if test $pkg_use_nbcompat_getopt_long = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_NBCOMPAT_GETOPT_LONG 1
-_ACEOF
-
-
-
- case " $LIBOBJS " in
- *" getopt_long.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
- ;;
-esac
-
-fi
-
pkg_use_nbcompat_vis=yes
for ac_header in vis.h
diff -r 1fd577fa5d79 -r 74bccf6db490 pkgtools/libnbcompat/files/configure.ac
--- a/pkgtools/libnbcompat/files/configure.ac Sun Mar 22 22:31:46 2009 +0000
+++ b/pkgtools/libnbcompat/files/configure.ac Sun Mar 22 22:33:13 2009 +0000
@@ -1,4 +1,4 @@
-dnl $NetBSD: configure.ac,v 1.71 2009/02/09 20:35:21 joerg Exp $
+dnl $NetBSD: configure.ac,v 1.72 2009/03/22 22:33:13 joerg Exp $
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52)
@@ -148,29 +148,19 @@
])
-pkg_use_nbcompat_getopt_long=yes
AC_CHECK_HEADERS([getopt.h], [
AC_MSG_TRY_COMPILE([for struct option], pkg_cv_have_struct_option,
[ #include <getopt.h> ], [ struct option X; ],
- [pkg_use_nbcompat_getopt_long=no],
- [pkg_use_nbcompat_getopt_long=yes])
+ [:],
+ [AC_LIBOBJ(getopt_long)])
])
if test "$enable_bsd_getopt" = yes; then
if test "$ac_cv_have_decl_optreset" = no; then
- pkg_use_nbcompat_getopt_long=yes
+ AC_LIBOBJ(getopt)
fi
fi
-if test $pkg_use_nbcompat_getopt_long = yes; then
- AC_DEFINE(HAVE_NBCOMPAT_GETOPT_LONG)
- AH_TEMPLATE([HAVE_NBCOMPAT_GETOPT_LONG], [
- Define to 1 if the `getopt_long' function is
- built into the library.
- ])
- AC_LIBOBJ(getopt_long)
-fi
-
dnl Check that this vis.h has *vis()-related functions because Solaris'
dnl vis.h doesn't. Also, only consider the header found if it defines
dnl all of the functions that we need.
diff -r 1fd577fa5d79 -r 74bccf6db490 pkgtools/libnbcompat/files/getopt.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/libnbcompat/files/getopt.c Sun Mar 22 22:33:13 2009 +0000
@@ -0,0 +1,149 @@
+/* $NetBSD: getopt.c,v 1.1 2009/03/22 22:33:13 joerg Exp $ */
+
+/*
+ * Copyright (c) 1987, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+
+__RCSID("$NetBSD: getopt.c,v 1.1 2009/03/22 22:33:13 joerg Exp $");
+
+#if 0
+#include "namespace.h"
+#endif
+
+#include <nbcompat/assert.h>
+#include <errno.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
+
+#undef __UNCONST
+#define __UNCONST(a) ((void *)(size_t)(const void *)(a))
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(getopt,_getopt)
+#endif
+#endif
+
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
+
+#define BADCH (int)'?'
+#define BADARG (int)':'
+#define EMSG ""
+
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt(int nargc, char * const nargv[], const char *ostr)
+{
+ static const char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
+
+ _DIAGASSERT(nargv != NULL);
+ _DIAGASSERT(ostr != NULL);
+
+ if (optreset || *place == 0) { /* update scanning pointer */
+ optreset = 0;
+ place = nargv[optind];
+ if (optind >= nargc || *place++ != '-') {
+ /* Argument is absent or is not an option */
+ place = EMSG;
+ return (-1);
+ }
+ optopt = *place++;
+ if (optopt == '-' && *place == 0) {
+ /* "--" => end of options */
+ ++optind;
+ place = EMSG;
+ return (-1);
+ }
+ if (optopt == 0) {
+ /* Solitary '-', treat as a '-' option
+ if the program (eg su) is looking for it. */
+ place = EMSG;
+ if (strchr(ostr, '-') == NULL)
+ return -1;
+ optopt = '-';
+ }
+ } else
+ optopt = *place++;
+
+ /* See if option letter is one the caller wanted... */
+ if (optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) {
+ if (*place == 0)
+ ++optind;
+ if (opterr && *ostr != ':')
+ (void)fprintf(stderr,
+ "%s: unknown option -- %c\n", getprogname(),
+ optopt);
+ return (BADCH);
+ }
+
+ /* Does this option need an argument? */
+ if (oli[1] != ':') {
+ /* don't need argument */
+ optarg = NULL;
+ if (*place == 0)
+ ++optind;
+ } else {
+ /* Option-argument is either the rest of this argument or the
+ entire next argument. */
+ if (*place)
+ optarg = __UNCONST(place);
+ else if (nargc > ++optind)
+ optarg = nargv[optind];
+ else {
+ /* option-argument absent */
+ place = EMSG;
+ if (*ostr == ':')
+ return (BADARG);
+ if (opterr)
+ (void)fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ getprogname(), optopt);
+ return (BADCH);
+ }
+ place = EMSG;
+ ++optind;
+ }
+ return (optopt); /* return option letter */
+}
diff -r 1fd577fa5d79 -r 74bccf6db490 pkgtools/libnbcompat/files/getopt_long.c
--- a/pkgtools/libnbcompat/files/getopt_long.c Sun Mar 22 22:31:46 2009 +0000
+++ b/pkgtools/libnbcompat/files/getopt_long.c Sun Mar 22 22:33:13 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getopt_long.c,v 1.9 2008/04/29 05:46:08 martin Exp $ */
+/* $NetBSD: getopt_long.c,v 1.10 2009/03/22 22:33:13 joerg Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -35,9 +35,7 @@
#include <nbcompat.h>
#include <nbcompat/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getopt_long.c,v 1.9 2008/04/29 05:46:08 martin Exp $");
-#endif /* LIBC_SCCS and not lint */
+__RCSID("$NetBSD: getopt_long.c,v 1.10 2009/03/22 22:33:13 joerg Exp $");
#if 0
#include "namespace.h"
@@ -45,9 +43,7 @@
#include <nbcompat/assert.h>
#include <nbcompat/err.h>
-#if HAVE_ERRNO_H
#include <errno.h>
-#endif
#if HAVE_NBTOOL_CONFIG_H
Home |
Main Index |
Thread Index |
Old Index