diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:40:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:40:05 +0000 |
commit | 4038ab95a094b363f1748f3dcb51511a1217475d (patch) | |
tree | 7f393d66a783f91ddd263c78d681e485cf4f45ca /librdfa/strtok_r.c | |
parent | Initial commit. (diff) | |
download | raptor2-upstream.tar.xz raptor2-upstream.zip |
Adding upstream version 2.0.16.upstream/2.0.16upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | librdfa/strtok_r.c | 52 |
1 files changed, 52 insertions, 0 deletions
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 <config.h> +#endif + +#include <string.h> +#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 */ |