+2004-10-01 Bruno Haible <bruno@clisp.org>
+
+ * MODULES.html.sh: Add strsep.
+
+2004-10-01 Yoann Vandoorselaere <yoann@prelude-ids.org>
+
+ * modules/strsep: New file.
+
2004-09-30 Paul Eggert <eggert@cs.ucla.edu>
* MODULES.html.sh (Support for systems lacking ISO C 99): Add snprintf.
func_module strdup
func_module strnlen
func_module strndup
+ func_module strsep
#func_module fstrcmp
func_module xstrndup
func_end_table
+2004-10-01 Yoann Vandoorselaere <yoann@prelude-ids.org>
+
+ * strsep.h: New file.
+ * strsep.c: New file.
+
2004-10-01 Simon Josefsson <jas@extundo.com>
* snprintf.c (snprintf): Handle size==0.
--- /dev/null
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ * Written by Yoann Vandoorselaere <yoann@prelude-ids.org>
+ *
+ * The file 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.
+ *
+ * This file 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 this file; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* Specification. */
+#include "strsep.h"
+
+#include <string.h>
+
+#include "strpbrk.h"
+
+char *
+strsep (char **stringp, const char *delim)
+{
+ char *start = *stringp;
+ char *ptr;
+
+ if (!start)
+ return NULL;
+
+ if (!*delim)
+ ptr = start + strlen (start);
+ else
+ {
+ ptr = strpbrk (start, delim);
+ if (!ptr)
+ {
+ *stringp = NULL;
+ return start;
+ }
+ }
+
+ *ptr = '\0';
+ *stringp = ptr + 1;
+
+ return start;
+}
--- /dev/null
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ * Written by Yoann Vandoorselaere <yoann@prelude-ids.org>
+ *
+ * The file 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.
+ *
+ * This file 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 this file; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ */
+
+#ifndef GNULIB_STRSEP_H_
+#define GNULIB_STRSEP_H_
+
+/*
+ * Get strsep, if available.
+ */
+#include <string.h>
+
+/* Searches the next delimiter (char listed in DELIM) starting at *STRINGP.
+ If one is found, it is overwritten with a NUL, and *STRINGP is advanced
+ to point to the next char after it. Otherwise, *STRINGP is set to NULL.
+ If *STRINGP was already NULL, nothing happens.
+ Returns the old value of *STRINGP.
+
+ This is a variant of strtok() that is multithread-safe and supports
+ empty fields.
+
+ Caveat: It modifies the original string.
+ Caveat: It doesn't work with multibyte strings unless all of the delimiter
+ characters are ASCII characters < 0x30. */
+
+extern char *strsep (char **stringp, const char *delim);
+
+#endif /* GNULIB_STRSEP_H_ */
+2004-10-01 Yoann Vandoorselaere <yoann@prelude-ids.org>
+
+ * strsep.m4: New file.
+
2004-09-30 Simon Josefsson <jas@extundo.com>
* snprintf.m4: New file.
--- /dev/null
+# strsep.m4 serial 1
+dnl Copyright (C) 2002, 2003, 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_STRSEP],
+[
+ AC_REPLACE_FUNCS(strsep)
+ AC_CHECK_DECLS_ONCE(strsep)
+ gl_PREREQ_STRSEP
+])
+
+# Prerequisites of lib/strsep.c.
+AC_DEFUN([gl_PREREQ_STRSEP], [:])
--- /dev/null
+Description:
+strsep() function: extract token from string.
+
+Files:
+lib/strsep.h
+lib/strsep.c
+m4/strsep.m4
+
+Depends-on:
+strpbrk
+
+configure.ac:
+gl_FUNC_STRSEP
+
+Makefile.am:
+lib_SOURCES += strsep.h
+
+Include:
+"strsep.h"
+
+License:
+LGPL
+
+Maintainer:
+Yoann Vandoorselaere