From 1cd53467c94908963bd0e5c7dece594f31ceb070 Mon Sep 17 00:00:00 2001 From: serassio <> Date: Mon, 3 Jul 2006 01:27:17 +0000 Subject: [PATCH] strsep() is not available on any platform, this add an own implementation. --- configure.in | 10 +++++++-- lib/Makefile.am | 11 ++++++++-- lib/strsep.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 4 deletions(-) create mode 100755 lib/strsep.c diff --git a/configure.in b/configure.in index 2a0b228784..ef30180f8b 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ dnl Configuration input file for Squid dnl -dnl $Id: configure.in,v 1.425 2006/07/02 16:53:46 serassio Exp $ +dnl $Id: configure.in,v 1.426 2006/07/02 19:27:17 serassio Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AM_CONFIG_HEADER(include/autoconf.h) AC_CONFIG_AUX_DIR(cfgaux) AC_CONFIG_SRCDIR([src/main.cc]) AM_INIT_AUTOMAKE([tar-ustar]) -AC_REVISION($Revision: 1.425 $)dnl +AC_REVISION($Revision: 1.426 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -2512,6 +2512,7 @@ AC_CHECK_FUNCS(\ srand48 \ srandom \ statfs \ + strsep \ sysconf \ syslog \ timegm \ @@ -2580,6 +2581,11 @@ if test "$ac_cv_func_snprintf" = "no" || test "$ac_cv_func_vsnprintf" = "no" ; t AM_CONDITIONAL(NEED_OWN_SNPRINTF, true) fi +AM_CONDITIONAL(NEED_OWN_STRSEP, false) +if test "$ac_cv_func_strsep" = "no" ; then + AM_CONDITIONAL(NEED_OWN_STRSEP, true) +fi + dnl dnl Test for va_copy dnl diff --git a/lib/Makefile.am b/lib/Makefile.am index 901fe024cc..672221f947 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in # -# $Id: Makefile.am,v 1.21 2006/05/27 00:58:15 hno Exp $ +# $Id: Makefile.am,v 1.22 2006/07/02 19:27:17 serassio Exp $ # DIST_SUBDIRS = libTrie cppunit-1.10.0 @@ -23,6 +23,11 @@ SNPRINTFSOURCE=snprintf.c else SNPRINTFSOURCE= endif +if NEED_OWN_STRSEP +STRSEPSOURCE=strsep.c +else +STRSEPSOURCE= +endif if NEED_OWN_MD5 MD5SOURCE=md5.c else @@ -48,7 +53,8 @@ noinst_LIBRARIES = \ EXTRA_libmiscutil_a_SOURCES = \ md5.c \ Profiler.c \ - snprintf.c + snprintf.c \ + strsep.c libmiscutil_a_SOURCES = \ MemPool.cc \ base64.c \ @@ -66,6 +72,7 @@ libmiscutil_a_SOURCES = \ safe_inet_addr.c \ $(SNPRINTFSOURCE) \ Splay.cc \ + $(STRSEPSOURCE) \ stub_memaccount.c \ util.c \ uudecode.c \ diff --git a/lib/strsep.c b/lib/strsep.c new file mode 100755 index 0000000000..62a475bcc5 --- /dev/null +++ b/lib/strsep.c @@ -0,0 +1,58 @@ +/* + * $Id: strsep.c,v 1.1 2006/07/02 19:27:17 serassio Exp $ + */ + +/* Copyright (C) 2004 Free Software Foundation, Inc. + * Written by Yoann Vandoorselaere + * + * 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 +#endif + +/* Specification. */ +#include "strsep.h" + +#include + +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; +} -- 2.47.3