diff options
author | Bryan Drewery <bryan@shatow.net> | 2016-05-20 21:45:19 +0300 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2016-05-20 21:45:19 +0300 |
commit | fdf59301aab25eb0105e19fbb572972d45d4671b (patch) | |
tree | 345b22c68150253929dddc5a46267e6c93f6569b /external | |
parent | 99b3286b9da0f7f0d045db8e58e07246c8dc52e5 (diff) |
Add compat for strchrnul(3) for FreeBSD 9.3
Diffstat (limited to 'external')
-rw-r--r-- | external/sh_compat/compat.c | 48 | ||||
-rw-r--r-- | external/sh_compat/compat.h | 9 | ||||
-rw-r--r-- | external/update_sh.sh | 2 |
3 files changed, 58 insertions, 1 deletions
diff --git a/external/sh_compat/compat.c b/external/sh_compat/compat.c new file mode 100644 index 00000000..dde91685 --- /dev/null +++ b/external/sh_compat/compat.c @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2016 Bryan Drewery <bdrewery@FreeBSD.org> + * Copyright (c) 2013 Niclas Zeising + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> + +#include <stddef.h> +#include <string.h> + +#include "config.h" + +#ifndef HAVE_STRCHRNUL +char * +strchrnul(const char *p, int ch) +{ + char c; + + c = ch; + for (;; ++p) { + if (*p == c || *p == '\0') + return ((char *)p); + } + /* NOTREACHED */ +} +#endif diff --git a/external/sh_compat/compat.h b/external/sh_compat/compat.h new file mode 100644 index 00000000..68723189 --- /dev/null +++ b/external/sh_compat/compat.h @@ -0,0 +1,9 @@ +#ifndef _SH_COMPAT_COMPAT_H +#define _SH_COMPAT_COMPAT_H + +#include "config.h" + +#ifndef HAVE_STRCHRNUL +char *strchrnul(const char*, int); +#endif +#endif diff --git a/external/update_sh.sh b/external/update_sh.sh index 85bcb72d..c7439812 100644 --- a/external/update_sh.sh +++ b/external/update_sh.sh @@ -35,5 +35,5 @@ cd "${ORIG_PWD}" sed -i '' -e 's,[[:<:]]st_mtim[[:>:]],st_mtimespec,g' "${DESTDIR}/test.c" git add -A "${DESTDIR}" -echo "sh_SOURCES= \\" +echo "sh_SOURCES= external/sh_compat/compat.c \\" find "${DESTDIR}" -name '*.c'|sed -e 's,$, \\,'|sort |