From 4038ab95a094b363f1748f3dcb51511a1217475d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:40:05 +0200 Subject: Adding upstream version 2.0.16. Signed-off-by: Daniel Baumann --- librdfa/strtok_r.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 librdfa/strtok_r.c (limited to 'librdfa/strtok_r.c') diff --git a/librdfa/strtok_r.c b/librdfa/strtok_r.c new file mode 100644 index 0000000..f07f9fb --- /dev/null +++ b/librdfa/strtok_r.c @@ -0,0 +1,52 @@ +/* This file is in the public domain */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include "strtok_r.h" + +#ifdef NEED_RDFA_STRTOK_R + +char * +rdfa_strtok_r(char *str, const char *delim, char **saveptr) +{ + char *p; + + if (str == NULL) + str = *saveptr; + + if (str == NULL) + return NULL; + + while (*str && strchr(delim, *str)) + str++; + + if (*str == '\0') + { + *saveptr = NULL; + return NULL; + } + + p = str; + while (*p && !strchr(delim, *p)) + p++; + + if (*p == '\0') + *saveptr = NULL; + else + { + *p = '\0'; + p++; + *saveptr = p; + } + + return str; +} + +#else /* ! NEED_RDFA_STRTOK_R */ + +typedef int blah; /* "ISO C forbids an empty translation unit" */ + +#endif /* NEED_RDFA_STRTOK_R */ -- cgit v1.2.3