pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/libnbcompat Add asprintf implementation based...
details: https://anonhg.NetBSD.org/pkgsrc/rev/b5bcf09f4424
branches: trunk
changeset: 530338:b5bcf09f4424
user: joerg <joerg%pkgsrc.org@localhost>
date: Mon Jun 25 21:35:03 2007 +0000
description:
Add asprintf implementation based on snprintf.
Add vsnprintf prototype as the function is implemented and used.
Add all the macros from NetBSD's sys/queue.h defined for the types
implemented.
Bump version to libnbcompat-20070622.
Tested by dmcmahill%NetBSD.org@localhost on Solaris.
OK jlam@, agc@
diffstat:
pkgtools/libnbcompat/Makefile | 4 +-
pkgtools/libnbcompat/files/asprintf.c | 98 ++++++++++++++
pkgtools/libnbcompat/files/configure | 21 +-
pkgtools/libnbcompat/files/configure.ac | 6 +-
pkgtools/libnbcompat/files/nbcompat/config.h.in | 3 +
pkgtools/libnbcompat/files/nbcompat/queue.h | 167 ++++++++++++++++++++++-
pkgtools/libnbcompat/files/nbcompat/stdio.h | 12 +-
7 files changed, 282 insertions(+), 29 deletions(-)
diffs (truncated from 493 to 300 lines):
diff -r 69657741c4f5 -r b5bcf09f4424 pkgtools/libnbcompat/Makefile
--- a/pkgtools/libnbcompat/Makefile Mon Jun 25 21:18:52 2007 +0000
+++ b/pkgtools/libnbcompat/Makefile Mon Jun 25 21:35:03 2007 +0000
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.49 2007/05/31 10:18:49 rillig Exp $
+# $NetBSD: Makefile,v 1.50 2007/06/25 21:35:03 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-20070531
+DISTNAME= libnbcompat-20070622
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
diff -r 69657741c4f5 -r b5bcf09f4424 pkgtools/libnbcompat/files/asprintf.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/libnbcompat/files/asprintf.c Mon Jun 25 21:35:03 2007 +0000
@@ -0,0 +1,98 @@
+/* $NetBSD: asprintf.c,v 1.1 2007/06/25 21:35:04 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDERS 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.
+ */
+
+#include <nbcompat.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+
+int
+asprintf(char **ret, const char *fmt, ...)
+{
+ va_list ap;
+ int retval;
+
+ va_start(ap, fmt);
+ retval = vasprintf(ret, fmt, ap);
+ va_end(ap);
+
+ return retval;
+}
+
+int
+vasprintf(char **ret, const char *fmt, va_list ap)
+{
+ char *buf, *new_buf;
+ size_t len;
+ int retval;
+
+ len = 128;
+ buf = malloc(len);
+ if (buf == NULL) {
+ *ret = NULL;
+ return -1;
+ }
+
+ retval = vsnprintf(buf, len, fmt, ap);
+ if (retval < 0) {
+ free(buf);
+ *ret = NULL;
+ return -1;
+ }
+
+ if (retval < len) {
+ new_buf = realloc(buf, retval + 1);
+ if (new_buf == NULL)
+ *ret = buf;
+ else
+ *ret = new_buf;
+ return retval;
+ }
+
+ len = (size_t)retval + 1;
+ new_buf = realloc(buf, len);
+ if (new_buf == NULL) {
+ free(buf);
+ *ret = NULL;
+ return -1;
+ }
+ retval = vsnprintf(buf, len, fmt, ap);
+ if (retval != len - 1) {
+ free(new_buf);
+ *ret = NULL;
+ return -1;
+ }
+ *ret = new_buf;
+ return retval;
+}
diff -r 69657741c4f5 -r b5bcf09f4424 pkgtools/libnbcompat/files/configure
--- a/pkgtools/libnbcompat/files/configure Mon Jun 25 21:18:52 2007 +0000
+++ b/pkgtools/libnbcompat/files/configure Mon Jun 25 21:35:03 2007 +0000
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for libnbcompat 20040911.
+# Generated by GNU Autoconf 2.61 for libnbcompat 20070622.
#
# Report bugs to <grant%NetBSD.org@localhost>.
#
@@ -574,8 +574,8 @@
# Identity of this package.
PACKAGE_NAME='libnbcompat'
PACKAGE_TARNAME='libnbcompat'
-PACKAGE_VERSION='20040911'
-PACKAGE_STRING='libnbcompat 20040911'
+PACKAGE_VERSION='20070622'
+PACKAGE_STRING='libnbcompat 20070622'
PACKAGE_BUGREPORT='grant%NetBSD.org@localhost'
# Factoring default headers for most tests.
@@ -1195,7 +1195,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libnbcompat 20040911 to adapt to many kinds of systems.
+\`configure' configures libnbcompat 20070622 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1265,7 +1265,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libnbcompat 20040911:";;
+ short | recursive ) echo "Configuration of libnbcompat 20070622:";;
esac
cat <<\_ACEOF
@@ -1343,7 +1343,7 @@
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-libnbcompat configure 20040911
+libnbcompat configure 20070622
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1357,7 +1357,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libnbcompat $as_me 20040911, which was
+It was created by libnbcompat $as_me 20070622, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -8887,7 +8887,8 @@
-for ac_func in err fgetln fnmatch fparseln getenv isblank \
+
+for ac_func in asprintf err fgetln fnmatch fparseln getenv isblank \
lchflags lchmod lchown lutimes mkdtemp mkstemp setenv setgroupent \
setpassent setprogname snprintf statvfs strdup strerror strlcat \
strlcpy strmode strsep strtoll unsetenv usleep utimes warn
@@ -11676,7 +11677,7 @@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by libnbcompat $as_me 20040911, which was
+This file was extended by libnbcompat $as_me 20070622, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -11725,7 +11726,7 @@
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-libnbcompat config.status 20040911
+libnbcompat config.status 20070622
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff -r 69657741c4f5 -r b5bcf09f4424 pkgtools/libnbcompat/files/configure.ac
--- a/pkgtools/libnbcompat/files/configure.ac Mon Jun 25 21:18:52 2007 +0000
+++ b/pkgtools/libnbcompat/files/configure.ac Mon Jun 25 21:35:03 2007 +0000
@@ -1,8 +1,8 @@
-dnl $NetBSD: configure.ac,v 1.54 2007/05/07 21:41:34 joerg Exp $
+dnl $NetBSD: configure.ac,v 1.55 2007/06/25 21:35:05 joerg Exp $
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52)
-AC_INIT([libnbcompat], [20040911], [grant%NetBSD.org@localhost])
+AC_INIT([libnbcompat], [20070622], [grant%NetBSD.org@localhost])
AC_CONFIG_HEADER(nbcompat/config.h)
AC_ARG_PROGRAM
@@ -216,7 +216,7 @@
AC_FUNC_STRERROR_R
AC_FUNC_VPRINTF
-AC_REPLACE_FUNCS([err fgetln fnmatch fparseln getenv isblank \
+AC_REPLACE_FUNCS([asprintf err fgetln fnmatch fparseln getenv isblank \
lchflags lchmod lchown lutimes mkdtemp mkstemp setenv setgroupent \
setpassent setprogname snprintf statvfs strdup strerror strlcat \
strlcpy strmode strsep strtoll unsetenv usleep utimes warn
diff -r 69657741c4f5 -r b5bcf09f4424 pkgtools/libnbcompat/files/nbcompat/config.h.in
--- a/pkgtools/libnbcompat/files/nbcompat/config.h.in Mon Jun 25 21:18:52 2007 +0000
+++ b/pkgtools/libnbcompat/files/nbcompat/config.h.in Mon Jun 25 21:35:03 2007 +0000
@@ -6,6 +6,9 @@
/* Define to 1 if you have the <alloca.h> header file. */
#undef HAVE_ALLOCA_H
+/* Define to 1 if you have the `snprintf' function. */
+#undef HAVE_ASPRINTF
+
/* Define to 1 if you have the <assert.h> header file. */
#undef HAVE_ASSERT_H
diff -r 69657741c4f5 -r b5bcf09f4424 pkgtools/libnbcompat/files/nbcompat/queue.h
--- a/pkgtools/libnbcompat/files/nbcompat/queue.h Mon Jun 25 21:18:52 2007 +0000
+++ b/pkgtools/libnbcompat/files/nbcompat/queue.h Mon Jun 25 21:35:03 2007 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: queue.h,v 1.2 2004/08/10 18:47:55 jlam Exp $ */
+/* $NetBSD: queue.h,v 1.3 2007/06/25 21:35:05 joerg Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -66,6 +66,32 @@
}
#endif
+#ifndef LIST_INIT
+#define LIST_INIT(head) do { \
+ (head)->lh_first = NULL; \
+} while (/*CONSTCOND*/0)
+#endif
+
+#ifndef LIST_INSERT_AFTER
+#define LIST_INSERT_AFTER(listelm, elm, field) do { \
+ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
+ (listelm)->field.le_next->field.le_prev = \
+ &(elm)->field.le_next; \
+ (listelm)->field.le_next = (elm); \
+ (elm)->field.le_prev = &(listelm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+#endif
+
+#ifndef LIST_INSERT_BEFORE
+#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
+ QUEUEDEBUG_LIST_OP((listelm), field) \
+ (elm)->field.le_prev = (listelm)->field.le_prev; \
+ (elm)->field.le_next = (listelm); \
+ *(listelm)->field.le_prev = (elm); \
+ (listelm)->field.le_prev = &(elm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+#endif
+
#ifndef LIST_INSERT_HEAD
#define LIST_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
@@ -75,12 +101,22 @@
} while (/*CONSTCOND*/0)
#endif
-#ifndef LIST_INIT
-#define LIST_INIT(head) do { \
- (head)->lh_first = NULL; \
+#ifndef LIST_REMOVE
+#define LIST_REMOVE(elm, field) do { \
+ if ((elm)->field.le_next != NULL) \
+ (elm)->field.le_next->field.le_prev = \
+ (elm)->field.le_prev; \
+ *(elm)->field.le_prev = (elm)->field.le_next; \
} while (/*CONSTCOND*/0)
#endif
+#ifndef LIST_FOREACH
Home |
Main Index |
Thread Index |
Old Index