Browse Source

Added strsep to gnulib, for check_snmp.c

Ton Voon 15 năm trước cách đây
mục cha
commit
f789a37b05
5 tập tin đã thay đổi với 101 bổ sung2 xóa
  1. 10 1
      gl/Makefile.am
  2. 2 1
      gl/m4/gnulib-cache.m4
  3. 6 0
      gl/m4/gnulib-comp.m4
  4. 25 0
      gl/m4/strsep.m4
  5. 58 0
      gl/strsep.c

+ 10 - 1
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
 
 

+ 2 - 1
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

+ 6 - 0
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

+ 25 - 0
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], [:])

+ 58 - 0
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;
+}