1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (compat_posix_string.c).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #include <compat/posix_string.h>
36 #include <compat/strl.h>
40 int retro_strcasecmp__(const char *a, const char *b)
54 return tolower(*a) - tolower(*b);
57 char *retro_strdup__(const char *orig)
59 size_t len = strlen(orig) + 1;
60 char *ret = (char*)malloc(len);
64 strlcpy(ret, orig, len);
68 int retro_isblank__(int c)
70 return (c == ' ') || (c == '\t');
73 char *retro_strtok_r__(char *str, const char *delim, char **saveptr)
76 if (!saveptr || !delim)
86 while (*first && strchr(delim, *first))
94 while (*ptr && !strchr(delim, *ptr))
97 *saveptr = ptr + (*ptr ? 1 : 0);
99 } while (strlen(first) == 0);