From: Paul Eggert Date: Tue, 22 Jun 2004 18:28:11 +0000 (+0000) Subject: Add argz module, which is autoupdated from libtool. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06a946707465c071bb0a15fcc7498532967679e1;p=pspp Add argz module, which is autoupdated from libtool. --- diff --git a/ChangeLog b/ChangeLog index 80f5b6f69a..314d12ba99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-06-22 Paul Eggert + + * modules/argz: Omit "#include". + + * MODULES.html.sh (func_all_modules): Add calloc, to match + 2004-06-01 addition of calloc module. + +2004-06-22 Gary V. Vaughan + + * modules/argz: New file. + * MODULES.html.sh (func_all_modules): Add argz. + 2004-06-12 Jim Meyering and Paul Eggert diff --git a/MODULES.html b/MODULES.html index cf036fda32..6ddf71f05b 100644 --- a/MODULES.html +++ b/MODULES.html @@ -2,7 +2,7 @@ Gnulib Module List - +

Gnulib Module List

@@ -82,6 +82,10 @@

Enhancements for ANSI C 89 functions

Memory management functions <stdlib.h>

+ + + + + + + +
calloc + calloc() function that is glibc compatible. +
eealloc Memory allocation with expensive empty allocations (glibc compatible). @@ -808,6 +812,10 @@ usually the host name including FQDN. argp Hierarchical processing of command line arguments.
argz + Argv style string arrays in a single null delimited char*. +
exitfail Set exit status for fatal signal. @@ -1036,6 +1044,13 @@ variables. Autoconf macro Depends on
calloc + #include <stdlib.h> + calloc.c + calloc.m4
AC_FUNC_CALLOC +
--- +
eealloc #include <eealloc.h> @@ -2656,6 +2671,13 @@ variables. argp.m4
gl_ARGP
alloca
getopt
strchrnul
sysexits
mempcpy
strndup
restrict
strcase
argz + #include <argz.h> + argz_.h
argz.c +
argz.m4
gl_FUNC_ARGZ +
--- +
exitfail #include "exitfail.h" @@ -2783,30 +2805,6 @@ variables. ---
-

Unclassified modules - please update MODULES.html.sh

- - - - - - - -
modules/ - lib/ - lib/ - m4/ -   -
Module - Header - Implementation - Autoconf macro - Depends on -
calloc - #include <stdlib.h> - calloc.c - calloc.m4
AC_FUNC_CALLOC -
--- -

Lone files - please create new modules containing them

 lib/progreloc.c
@@ -2842,6 +2840,6 @@ variables.
       
  • A testsuite
    - Generated from MODULES.html.sh on 14 June 2004. + Generated from MODULES.html.sh on 22 June 2004. diff --git a/MODULES.html.sh b/MODULES.html.sh index fa65b0f2a5..cf222dabf1 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -1904,6 +1904,7 @@ func_all_modules () func_begin_table func_module argp + func_module argz func_module exitfail func_module c-stack func_module error diff --git a/config/ChangeLog b/config/ChangeLog index 05bad0227c..915139ba04 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,10 @@ +2004-06-22 Paul Eggert + + * srclist-update: Don't insist on "USA." before the close-comment, + as libtool omits the period and puts the */ on a separate line. + * srclist.txt: Add argz.c, argz_.h, argz.m4. + * srclistvars.sh: Add LIBTOOL (for eggert only). + 2004-05-18 Karl Berry * srclist.txt: break link for vasnprintf.c. diff --git a/config/srclist-update b/config/srclist-update index 0ca4204534..a77e0e0302 100755 --- a/config/srclist-update +++ b/config/srclist-update @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: srclist-update,v 1.14 2003-08-15 18:04:34 eggert Exp $ +# $Id: srclist-update,v 1.15 2004-06-22 18:28:25 eggert Exp $ # # Check for files in directory $1 being up to date, according to the # list on stdin. Don't actually make any changes, just show the diffs. @@ -58,7 +58,7 @@ fixlicense=' # with this program; if not, write to the Free Software Foundation,\ # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - /Th[ei][ s].* is free software/,/USA\. *\*\//c\ + /Th[ei][ s].* is free software/,/\*\//c\ This program is free software; you can redistribute it and/or modify\ it under the terms of the GNU General Public License as published by\ the Free Software Foundation; either version 2, or (at your option)\ diff --git a/config/srclist.txt b/config/srclist.txt index 2b10c3dfdd..26cf7a15c6 100644 --- a/config/srclist.txt +++ b/config/srclist.txt @@ -1,4 +1,4 @@ -# $Id: srclist.txt,v 1.39 2004-05-18 12:22:41 karl Exp $ +# $Id: srclist.txt,v 1.40 2004-06-22 18:28:25 eggert Exp $ # Files for which we are not the source. See ./srclistvars.sh for the # variable definitions. @@ -173,3 +173,7 @@ $LIBCSRC/sysdeps/generic/strtoul.c lib gpl #$LIBCSRC/sysdeps/unix/sysv/gethostname.c lib gpl #$LIBCSRC/sysdeps/unix/mkdir.c lib gpl #$LIBCSRC/sysdeps/unix/utime.c lib gpl + +$LIBTOOL/libltdl/argz.c lib gpl +$LIBTOOL/libltdl/argz_.h lib gpl +$LIBTOOL/m4/argz.m4 m4 diff --git a/config/srclistvars.sh b/config/srclistvars.sh index 489f120daf..d65743df53 100644 --- a/config/srclistvars.sh +++ b/config/srclistvars.sh @@ -1,4 +1,4 @@ -# $Id: srclistvars.sh,v 1.15 2004-03-09 19:42:23 eggert Exp $ +# $Id: srclistvars.sh,v 1.16 2004-06-22 18:28:25 eggert Exp $ # Variables for srclist-update and srclist.txt. # Will change for each user. @@ -10,6 +10,7 @@ eggert) : ${GNUCONFIG=../config} : ${GNUORG=../gnuorg} : ${GNUWWWLICENSES=$GNUORG} + : ${LIBTOOL=../libtool} : ${LIBCSRC=../libc} : ${TEXINFOSRC=../texinfo} ;; diff --git a/lib/ChangeLog b/lib/ChangeLog index 881a33b15a..79503401dd 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2004-06-22 Paul Eggert + + * argz.c, argz_.h: New files, which are autoupdated from libtool. + 2004-06-01 Jim Meyering * calloc.c: New file. diff --git a/lib/argz.c b/lib/argz.c new file mode 100644 index 0000000000..cfa0829f1a --- /dev/null +++ b/lib/argz.c @@ -0,0 +1,227 @@ +/* argz.c -- argz implementation for non-glibc systems + Copyright (C) 2004 Free Software Foundation, Inc. + Originally by Gary V. Vaughan + + NOTE: The canonical source of this file is maintained with the + GNU Libtool package. Report bugs to bug-libtool@gnu.org. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Provide our wierdo HAVE_CONFIG_H rvalue for other clients. */ +#if !defined(LTDL) && defined(HAVE_CONFIG_H) +# define HAVE_CONFIG_H +#endif + +#if defined(HAVE_CONFIG_H) +# include HAVE_CONFIG_H +#endif + +#include + +#include +#include +#include +#include +#include + +#if defined(HAVE_STRING_H) +# include +#elif defined(HAVE_STRINGS_H) +# include +#endif +#if defined(HAVE_MEMORY_H) +# include +#endif + +#define EOS_CHAR '\0' + +error_t +argz_append (char **pargz, size_t *pargz_len, const char *buf, size_t buf_len) +{ + size_t argz_len; + char *argz; + + assert (pargz); + assert (pargz_len); + assert ((*pargz && *pargz_len) || (!*pargz && !*pargz_len)); + + /* If nothing needs to be appended, no more work is required. */ + if (buf_len == 0) + return 0; + + /* Ensure there is enough room to append BUF_LEN. */ + argz_len = *pargz_len + buf_len; + argz = (char *) realloc (*pargz, argz_len); + if (!argz) + return ENOMEM; + + /* Copy characters from BUF after terminating '\0' in ARGZ. */ + memcpy (argz + *pargz_len, buf, buf_len); + + /* Assign new values. */ + *pargz = argz; + *pargz_len = argz_len; + + return 0; +} + + +error_t +argz_create_sep (const char *str, int delim, char **pargz, size_t *pargz_len) +{ + size_t argz_len; + char *argz = 0; + + assert (str); + assert (pargz); + assert (pargz_len); + + /* Make a copy of STR, but replacing each occurence of + DELIM with '\0'. */ + argz_len = 1+ strlen (str); + if (argz_len) + { + const char *p; + char *q; + + argz = (char *) malloc (argz_len); + if (!argz) + return ENOMEM; + + for (p = str, q = argz; *p != EOS_CHAR; ++p) + { + if (*p == delim) + { + /* Ignore leading delimiters, and fold consecutive + delimiters in STR into a single '\0' in ARGZ. */ + if ((q > argz) && (q[-1] != EOS_CHAR)) + *q++ = EOS_CHAR; + else + --argz_len; + } + else + *q++ = *p; + } + /* Copy terminating EOS_CHAR. */ + *q = *p; + } + + /* If ARGZ_LEN has shrunk to nothing, release ARGZ's memory. */ + if (!argz_len) + argz = (free (argz), (char *) 0); + + /* Assign new values. */ + *pargz = argz; + *pargz_len = argz_len; + + return 0; +} + + +error_t +argz_insert (char **pargz, size_t *pargz_len, char *before, const char *entry) +{ + assert (pargz); + assert (pargz_len); + assert (entry && *entry); + + /* No BEFORE address indicates ENTRY should be inserted after the + current last element. */ + if (!before) + return argz_append (pargz, pargz_len, entry, 1+ strlen (entry)); + + /* This probably indicates a programmer error, but to preserve + semantics, scan back to the start of an entry if BEFORE points + into the middle of it. */ + while ((before > *pargz) && (before[-1] != EOS_CHAR)) + --before; + + { + size_t entry_len = 1+ strlen (entry); + size_t argz_len = *pargz_len + entry_len; + size_t offset = before - *pargz; + char *argz = (char *) realloc (*pargz, argz_len); + + if (!argz) + return ENOMEM; + + /* Make BEFORE point to the equivalent offset in ARGZ that it + used to have in *PARGZ incase realloc() moved the block. */ + before = argz + offset; + + /* Move the ARGZ entries starting at BEFORE up into the new + space at the end -- making room to copy ENTRY into the + resulting gap. */ + memmove (before + entry_len, before, *pargz_len - offset); + memcpy (before, entry, entry_len); + + /* Assign new values. */ + *pargz = argz; + *pargz_len = argz_len; + } + + return 0; +} + + +char * +argz_next (char *argz, size_t argz_len, const char *entry) +{ + assert ((argz && argz_len) || (!argz && !argz_len)); + + if (entry) + { + /* Either ARGZ/ARGZ_LEN is empty, or ENTRY points into an address + within the ARGZ vector. */ + assert ((!argz && !argz_len) + || ((argz <= entry) && (entry < (argz + argz_len)))); + + /* Move to the char immediately after the terminating + '\0' of ENTRY. */ + entry = 1+ strchr (entry, EOS_CHAR); + + /* Return either the new ENTRY, or else NULL if ARGZ is + exhausted. */ + return (entry >= argz + argz_len) ? 0 : (char *) entry; + } + else + { + /* This should probably be flagged as a programmer error, + since starting an argz_next loop with the iterator set + to ARGZ is safer. To preserve semantics, handle the NULL + case by returning the start of ARGZ (if any). */ + if (argz_len > 0) + return argz; + else + return 0; + } +} + + +void +argz_stringify (char *argz, size_t argz_len, int sep) +{ + assert ((argz && argz_len) || (!argz && !argz_len)); + + if (sep) + { + --argz_len; /* don't stringify the terminating EOS */ + while (--argz_len > 0) + { + if (argz[argz_len] == EOS_CHAR) + argz[argz_len] = sep; + } + } +} diff --git a/lib/argz_.h b/lib/argz_.h new file mode 100644 index 0000000000..423a071b21 --- /dev/null +++ b/lib/argz_.h @@ -0,0 +1,49 @@ +/* lt__argz.h -- internal argz interface for non-glibc systems + Copyright (C) 2004 Free Software Foundation, Inc. + Originally by Gary V. Vaughan + + NOTE: The canonical source of this file is maintained with the + GNU Libtool package. Report bugs to bug-libtool@gnu.org. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if !defined(LT__ARGZ_H) +#define LT__ARGZ_H 1 + +#include +#include + +#if defined(LTDL) +# include "lt__glibc.h" +#endif + +#if defined(_cplusplus) +extern "C" { +#endif + +error_t argz_append (char **pargz, size_t *pargz_len, + const char *buf, size_t buf_len); +error_t argz_create_sep (const char *str, int delim, + char **pargz, size_t *pargz_len); +error_t argz_insert (char **pargz, size_t *pargz_len, + char *before, const char *entry); +char * argz_next (char *argz, size_t argz_len, const char *entry); +void argz_stringify (char *argz, size_t argz_len, int sep); + +#if defined(_cplusplus) +} +#endif + +#endif /*!defined(LT__ARGZ_H)*/ diff --git a/m4/ChangeLog b/m4/ChangeLog index 86cfac1436..fedc0f7581 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2004-06-22 Paul Eggert + + * argz.m4: New file, which is autoupdated from libtool. + 2004-06-01 Jim Meyering * calloc.m4: New file. diff --git a/m4/argz.m4 b/m4/argz.m4 new file mode 100644 index 0000000000..66f3bc1e71 --- /dev/null +++ b/m4/argz.m4 @@ -0,0 +1,43 @@ +# Portability macros for glibc argz. -*- Autoconf -*- +# Written by Gary V. Vaughan + +# Copyright (C) 2004 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 1 + +AC_DEFUN([gl_FUNC_ARGZ], +[gl_PREREQ_ARGZ + +AC_CHECK_HEADERS([argz.h], [], [], [AC_INCLUDES_DEFAULT]) + +AC_CHECK_TYPES([error_t], + [], + [AC_DEFINE([error_t], [int], + [Define to a type to use for `error_t' if it is not otherwise available.])], + [#if defined(HAVE_ARGZ_H) +# include +#endif]) + +ARGZ_H= +AC_CHECK_FUNCS([argz_append argz_create_sep argz_insert argz_next \ + argz_stringify], [], [ARGZ_H=argz.h; AC_LIBOBJ([argz])]) +AC_SUBST([ARGZ_H]) +]) + +# Prerequisites of lib/argz.c. +AC_DEFUN([gl_PREREQ_ARGZ], [:]) diff --git a/modules/argz b/modules/argz new file mode 100644 index 0000000000..5f59ae6be9 --- /dev/null +++ b/modules/argz @@ -0,0 +1,30 @@ +Description: +Argv style string arrays in a single null delimited char*. + +Files: +lib/argz_.h +lib/argz.c +m4/argz.m4 + +Depends-on: + +configure.ac: +gl_FUNC_ARGZ + +Makefile.am: +BUILT_SOURCES += $(ARGZ_H) +EXTRA_DIST += argz_.h + +# We need the following in order to create an when the system +# doesn't have one that works with the given compiler. +all-local $(lib_OBJECTS): $(ARGZ_H) +argz.h: argz_.h + cp $(srcdir)/argz_.h $@-t + mv $@-t $@ +MOSTLYCLEANFILES += argz.h argz.h-t + +Include: + + +Maintainer: +bug-libtool@gnu.org