bsdstubs: add strtok_r() from musl if unavailable on a platform (closes #66)

feature/tap-sh
William Pitcock 2014-07-01 23:39:22 -05:00
parent c80229c646
commit 0161be992e
3 changed files with 47 additions and 1 deletions

View File

@ -125,3 +125,45 @@ char *strndup(const char *src, size_t len)
}
#endif
#ifndef HAVE_STRTOK_R
/*
* Copyright (c) 2005-2014 Rich Felker
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
char *strtok_r(char *s, const char *sep, char **p)
{
if (!s && !(s = *p))
return NULL;
s += strspn(s, sep);
if (!*s)
return *p = 0;
*p = s + strcspn(s, sep);
if (**p)
*(*p)++ = 0;
else
*p = 0;
return s;
}
#endif

View File

@ -31,4 +31,8 @@ extern size_t strlcat(char *dst, const char *src, size_t siz);
extern char *strndup(const char *src, size_t len);
#endif
#ifndef HAVE_STRTOK_R
extern char *strtok_r(char *s, const char *sep, char **p);
#endif
#endif

View File

@ -15,7 +15,7 @@ AC_PREREQ([2.68])
AC_INIT([pkgconf], [0.9.6], [http://github.com/pkgconf/pkgconf/issues])
AC_CONFIG_SRCDIR([pkg.c])
AC_CONFIG_HEADERS([config.h])
AC_CHECK_FUNCS([strlcpy strlcat strndup])
AC_CHECK_FUNCS([strlcpy strlcat strndup strtok_r])
AC_ARG_ENABLE([strict],