+2004-08-02 Simon Josefsson <jas@extundo.com>
+
+ * modules/getsubopt: New file.
+ * MODULES.html.sh (Support for systems lacking POSIX:2001): Add
+ getsubopt.
+
2004-08-05 Paul Eggert <eggert@cs.ucla.edu>
Merge from coreutils.
func_module ftruncate
func_module getgroups
func_module gethostname
+ func_module getsubopt
func_module gettimeofday
func_module mkdir
func_module mkstemp
+2004-08-02 Simon Josefsson <jas@extundo.com>
+
+ * getsubopt.h: New file, with comments from Bruno Haible.
+ * getsubopt.c: New file, from glibc, but slightly modified based on
+ suggestions from Paul Eggert <eggert@cs.ucla.edu>.
+
2004-08-05 Paul Eggert <eggert@cs.ucla.edu>
Merge from coreutils.
--- /dev/null
+/* Parse comma separate list into words.
+ Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+#include <string.h>
+
+#if !_LIBC
+/* This code is written for inclusion in gnu-libc, and uses names in
+ the namespace reserved for libc. If we're compiling in gnulib,
+ define those names to be the normal ones instead. */
+# include "strchrnul.h"
+# undef __strchrnul
+# define __strchrnul strchrnul
+#endif
+
+/* Parse comma separated suboption from *OPTIONP and match against
+ strings in TOKENS. If found return index and set *VALUEP to
+ optional value introduced by an equal sign. If the suboption is
+ not part of TOKENS return in *VALUEP beginning of unknown
+ suboption. On exit *OPTIONP is set to the beginning of the next
+ token or at the terminating NUL character. */
+int
+getsubopt (char **optionp, char *const *tokens, char **valuep)
+{
+ char *endp, *vstart;
+ int cnt;
+
+ if (**optionp == '\0')
+ return -1;
+
+ /* Find end of next token. */
+ endp = __strchrnul (*optionp, ',');
+
+ /* Find start of value. */
+ vstart = memchr (*optionp, '=', endp - *optionp);
+ if (vstart == NULL)
+ vstart = endp;
+
+ /* Try to match the characters between *OPTIONP and VSTART against
+ one of the TOKENS. */
+ for (cnt = 0; tokens[cnt] != NULL; ++cnt)
+ if (strncmp (*optionp, tokens[cnt], vstart - *optionp) == 0
+ && tokens[cnt][vstart - *optionp] == '\0')
+ {
+ /* We found the current option in TOKENS. */
+ *valuep = vstart != endp ? vstart + 1 : NULL;
+
+ if (*endp != '\0')
+ *endp++ = '\0';
+ *optionp = endp;
+
+ return cnt;
+ }
+
+ /* The current suboption does not match any option. */
+ *valuep = *optionp;
+
+ if (*endp != '\0')
+ *endp++ = '\0';
+ *optionp = endp;
+
+ return -1;
+}
--- /dev/null
+/* Parse comma separate list into words.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ Contributed by Simon Josefsson <jas@extundo.com>, 2004.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Assuming *OPTIONP is a comma separated list of elements of the form
+ "token" or "token=value", getsubopt parses the first of these elements.
+ If the first element refers to a "token" that is member of the given
+ NULL-terminated array of tokens:
+ - It replaces the comma with a NUL byte, updates *OPTIONP to point past
+ the first option and the comma, sets *VALUEP to the value of the
+ element (or NULL if it doesn't contain an "=" sign),
+ - It returns the index of the "token" in the given array of tokens.
+ Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
+ For more details see the POSIX:2001 specification.
+ http://www.opengroup.org/onlinepubs/009695399/functions/getsubopt.html */
+
+#if HAVE_GETSUBOPT
+
+/* Get getsubopt declaration. */
+#include <stdlib.h>
+
+#else
+
+extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
+
+#endif
+2004-08-02 Simon Josefsson <jas@extundo.com>
+
+ * getsubopt.m4: New file.
+
2004-08-05 Paul Eggert <eggert@cs.ucla.edu>
Merge from coreutils.
--- /dev/null
+# getsubopt.m4 serial 1
+dnl Copyright (C) 2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License. As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+AC_DEFUN([gl_FUNC_GETSUBOPT],
+[
+ dnl Persuade glibc <stdlib.h> to declare getsubopt().
+ AC_REQUIRE([AC_GNU_SOURCE])
+
+ AC_REPLACE_FUNCS(getsubopt)
+ if test $ac_cv_func_getsubopt = no; then
+ gl_PREREQ_GETSUBOPT
+ fi
+])
+
+# Prerequisites of lib/getsubopt.c.
+AC_DEFUN([gl_PREREQ_GETSUBOPT], [:])
--- /dev/null
+Description:
+getsubopt: Parse comma separate list into words.
+
+Files:
+lib/getsubopt.h
+lib/getsubopt.c
+m4/getsubopt.m4
+
+Depends-on:
+strchrnul
+
+configure.ac:
+gl_FUNC_GETSUBOPT
+
+Makefile.am:
+lib_SOURCES += getsubopt.h
+
+Include:
+"getsubopt.h"
+
+Maintainer:
+all, glibc