WinGui: Fix another instance of the Caliburn vs Json.net sillyness where objects...
[HandBrake.git] / libhb / compat.c
blob440074bc2e7bca441a606ad2154b54fb89ee0fce
1 /* compat.c
3 Copyright (c) 2003-2015 HandBrake Team
4 This file is part of the HandBrake source code
5 Homepage: <http://handbrake.fr/>.
6 It may be used under the terms of the GNU General Public License v2.
7 For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
8 */
10 #include "compat.h"
12 #ifdef HB_NEED_STRTOK_R
13 #include <string.h>
15 char *strtok_r(char *s, const char *delim, char **save_ptr)
17 char *token;
19 if (s == NULL) s = *save_ptr;
21 /* Scan leading delimiters. */
22 s += strspn(s, delim);
23 if (*s == '\0') return NULL;
25 /* Find the end of the token. */
26 token = s;
27 s = strpbrk(token, delim);
28 if (s == NULL)
30 /* This token finishes the string. */
31 *save_ptr = strchr(token, '\0');
33 else
35 /* Terminate the token and make *save_ptr point past it. */
36 *s = '\0';
37 *save_ptr = s + 1;
40 return token;
42 #endif // HB_NEED_STRTOK_R