From: Pietro Cerutti Date: Mon, 23 Jan 2017 16:33:35 +0000 (+0000) Subject: Remove in-house implementation of strtok_r X-Git-Tag: neomutt-20170128~5^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24a5acf303d5c72148dcb46ce03aa05011a5c3a9;p=neomutt Remove in-house implementation of strtok_r Issue: #325 --- diff --git a/configure.ac b/configure.ac index b526d8770..9157cba5c 100644 --- a/configure.ac +++ b/configure.ac @@ -454,7 +454,7 @@ AC_CHECK_HEADERS(unix.h) AC_CHECK_FUNCS(setrlimit getsid) AC_CHECK_FUNCS(fgets_unlocked fgetc_unlocked) -AC_CHECK_FUNCS(strcasecmp strncasecmp setenv strdup strsep) +AC_CHECK_FUNCS(strcasecmp strncasecmp setenv strdup strsep strtok_r) AC_MSG_CHECKING(for sig_atomic_t in signal.h) AC_EGREP_HEADER(sig_atomic_t,signal.h, @@ -493,7 +493,7 @@ AC_CHECK_TYPE(ssize_t, int) AC_CHECK_FUNCS(fgetpos memmove setegid srand48 strerror) -AC_REPLACE_FUNCS([strtok_r wcscasecmp]) +AC_REPLACE_FUNCS([wcscasecmp]) AC_REPLACE_FUNCS([strcasestr mkdtemp]) AC_CHECK_FUNC(getopt) diff --git a/protos.h b/protos.h index e807ace06..f3a4ecacb 100644 --- a/protos.h +++ b/protos.h @@ -560,10 +560,6 @@ int ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *); /* prototypes for compatibility functions */ -#ifndef HAVE_STRTOK_R -char *strtok_r (char *, const char *, char **); -#endif - #ifndef HAVE_WCSCASECMP int wcscasecmp (const wchar_t *a, const wchar_t *b); #endif diff --git a/strtok_r.c b/strtok_r.c deleted file mode 100644 index a4268dd88..000000000 --- a/strtok_r.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Reentrant string tokenizer. Generic version. - Copyright (C) 1991,1996-1999,2001,2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library 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. - - The GNU C Library 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 the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -/* Taken from glibc 2.6.1 */ - -/* Parse S into tokens separated by characters in DELIM. - If S is NULL, the saved pointer in SAVE_PTR is used as - the next starting point. For example: - char s[] = "-abc-=-def"; - char *sp; - x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" - x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL - x = strtok_r(NULL, "=", &sp); // x = NULL - // s = "abc\0-def\0" -*/ -char * -strtok_r (char *s, const char *delim, char **save_ptr) -{ - char *token; - - if (s == NULL) - s = *save_ptr; - - /* Scan leading delimiters. */ - s += strspn (s, delim); - if (*s == '\0') - { - *save_ptr = s; - return NULL; - } - - /* Find the end of the token. */ - token = s; - s = strpbrk (token, delim); - if (s == NULL) - /* This token finishes the string. */ - *save_ptr = strchr (token, '\0'); - else - { - /* Terminate the token and make *SAVE_PTR point past it. */ - *s = '\0'; - *save_ptr = s + 1; - } - return token; -}