diff options
author | Ton Voon <ton.voon@opsera.com> | 2010-06-24 09:57:07 +0100 |
---|---|---|
committer | Ton Voon <ton.voon@opsera.com> | 2010-06-24 09:57:07 +0100 |
commit | f789a37b057b6f34820ea4f95d63f53b5a84c980 (patch) | |
tree | 73b532f430f5e09ed8123824cf6ac852116471eb /gl | |
parent | b8e2850c1add8031a11d951bec1459b203582299 (diff) | |
download | monitoring-plugins-f789a37b057b6f34820ea4f95d63f53b5a84c980.tar.gz |
Added strsep to gnulib, for check_snmp.c
Diffstat (limited to 'gl')
-rw-r--r-- | gl/Makefile.am | 11 | ||||
-rw-r--r-- | gl/m4/gnulib-cache.m4 | 3 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 6 | ||||
-rw-r--r-- | gl/m4/strsep.m4 | 25 | ||||
-rw-r--r-- | gl/strsep.c | 58 |
5 files changed, 101 insertions, 2 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index 7954b034..2f5f9c43 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -9,7 +9,7 @@ # 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 @@ -1367,6 +1367,15 @@ EXTRA_libgnu_a_SOURCES += strnlen.c ## 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 97b1849b..f23cb519 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -15,7 +15,7 @@ # 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([]) @@ -32,6 +32,7 @@ gl_MODULES([ gettext mountlist regex + strsep timegm vasprintf vsnprintf diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index f4031cc7..73e63654 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -106,6 +106,7 @@ AC_DEFUN([gl_EARLY], # 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: @@ -327,6 +328,9 @@ AC_DEFUN([gl_INIT], # 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]) @@ -634,6 +638,7 @@ AC_DEFUN([gl_FILE_LIST], [ 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 @@ -762,6 +767,7 @@ AC_DEFUN([gl_FILE_LIST], [ 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 new file mode 100644 index 00000000..fb4d396b --- /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 new file mode 100644 index 00000000..a2a3ffa3 --- /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; +} |