summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b8e2850)
raw | patch | inline | side by side (parent: b8e2850)
author | Ton Voon <ton.voon@opsera.com> | |
Thu, 24 Jun 2010 08:57:07 +0000 (09:57 +0100) | ||
committer | Ton Voon <ton.voon@opsera.com> | |
Thu, 24 Jun 2010 08:57:07 +0000 (09:57 +0100) |
gl/Makefile.am | patch | blob | history | |
gl/m4/gnulib-cache.m4 | patch | blob | history | |
gl/m4/gnulib-comp.m4 | patch | blob | history | |
gl/m4/strsep.m4 | [new file with mode: 0644] | patch | blob |
gl/strsep.c | [new file with mode: 0644] | patch | blob |
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 7954b0344a79881c6830b8dcb768f2759052337d..2f5f9c43f376f46d9fdbb7b3f3b8a568b064129b 100644 (file)
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex timegm vasprintf vsnprintf
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex strsep timegm vasprintf vsnprintf
AUTOMAKE_OPTIONS = 1.5 gnits
## end gnulib module strnlen
+## begin gnulib module strsep
+
+
+EXTRA_DIST += strsep.c
+
+EXTRA_libgnu_a_SOURCES += strsep.c
+
+## end gnulib module strsep
+
## begin gnulib module strstr-simple
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index 97b1849b0c407ff84c0e7c91b99c3a47e295f933..f23cb519b3e66ebdb147264c3acbd7ab2e4e4623 100644 (file)
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex timegm vasprintf vsnprintf
+# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex strsep timegm vasprintf vsnprintf
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
gettext
mountlist
regex
+ strsep
timegm
vasprintf
vsnprintf
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index f4031cc7c9edde482d0e565a7c1a4ca77613443d..73e6365453dba546b652595e9e61c40289f3f9bb 100644 (file)
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
# Code from module string:
# Code from module strndup:
# Code from module strnlen:
+ # Code from module strsep:
# Code from module strstr-simple:
# Code from module sys_socket:
# Code from module sys_stat:
# Code from module strnlen:
gl_FUNC_STRNLEN
gl_STRING_MODULE_INDICATOR([strnlen])
+ # Code from module strsep:
+ gl_FUNC_STRSEP
+ gl_STRING_MODULE_INDICATOR([strsep])
# Code from module strstr-simple:
gl_FUNC_STRSTR_SIMPLE
gl_STRING_MODULE_INDICATOR([strstr])
lib/stripslash.c
lib/strndup.c
lib/strnlen.c
+ lib/strsep.c
lib/strstr.c
lib/sys_socket.in.h
lib/sys_stat.in.h
m4/string_h.m4
m4/strndup.m4
m4/strnlen.m4
+ m4/strsep.m4
m4/strstr.m4
m4/sys_socket_h.m4
m4/sys_stat_h.m4
diff --git a/gl/m4/strsep.m4 b/gl/m4/strsep.m4
--- /dev/null
+++ b/gl/m4/strsep.m4
@@ -0,0 +1,25 @@
+# strsep.m4 serial 9
+dnl Copyright (C) 2002, 2003, 2004, 2007, 2009, 2010 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_STRSEP],
+[
+ dnl Persuade glibc <string.h> to declare strsep().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ dnl The strsep() declaration in lib/string.in.h uses 'restrict'.
+ AC_REQUIRE([AC_C_RESTRICT])
+
+ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_REPLACE_FUNCS([strsep])
+ if test $ac_cv_func_strsep = no; then
+ HAVE_STRSEP=0
+ gl_PREREQ_STRSEP
+ fi
+])
+
+# Prerequisites of lib/strsep.c.
+AC_DEFUN([gl_PREREQ_STRSEP], [:])
diff --git a/gl/strsep.c b/gl/strsep.c
--- /dev/null
+++ b/gl/strsep.c
@@ -0,0 +1,58 @@
+/* Copyright (C) 2004, 2007, 2009, 2010 Free Software Foundation, Inc.
+
+ Written by Yoann Vandoorselaere <yoann@prelude-ids.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 3, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include <string.h>
+
+char *
+strsep (char **stringp, const char *delim)
+{
+ char *start = *stringp;
+ char *ptr;
+
+ if (start == NULL)
+ return NULL;
+
+ /* Optimize the case of no delimiters. */
+ if (delim[0] == '\0')
+ {
+ *stringp = NULL;
+ return start;
+ }
+
+ /* Optimize the case of one delimiter. */
+ if (delim[1] == '\0')
+ ptr = strchr (start, delim[0]);
+ else
+ /* The general case. */
+ ptr = strpbrk (start, delim);
+ if (ptr == NULL)
+ {
+ *stringp = NULL;
+ return start;
+ }
+
+ *ptr = '\0';
+ *stringp = ptr + 1;
+
+ return start;
+}