beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / poppler / strtok_r.cpp
blob6483e0f7be9149a9bfb127518aba753bc9487150
1 /* Reentrant string tokenizer. Generic version.
2 Copyright (C) 1991,1996-1999,2001,2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 /* Copyright (C) 1991,93,96,97,99,2000,2002 Free Software Foundation, Inc.
21 This file is part of the GNU C Library.
22 Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
23 with help from Dan Sahlin (dan@sics.se) and
24 commentary by Jim Blandy (jimb@ai.mit.edu);
25 adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
26 and implemented by Roland McGrath (roland@ai.mit.edu).
28 The GNU C Library is free software; you can redistribute it and/or
29 modify it under the terms of the GNU Lesser General Public
30 License as published by the Free Software Foundation; either
31 version 2.1 of the License, or (at your option) any later version.
33 The GNU C Library is distributed in the hope that it will be useful,
34 but WITHOUT ANY WARRANTY; without even the implied warranty of
35 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36 Lesser General Public License for more details.
38 You should have received a copy of the GNU Lesser General Public
39 License along with the GNU C Library; if not, write to the Free
40 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
41 02111-1307 USA. */
43 //========================================================================
45 // Modified under the Poppler project - http://poppler.freedesktop.org
47 // All changes made under the Poppler project to this file are licensed
48 // under GPL version 2 or later
50 // Copyright (C) 2012 Alexey Pavlov <alexpux@gmail.com>
51 // Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
53 // To see a description of the changes please see the Changelog file that
54 // came with your tarball or type make ChangeLog if you are building from git
56 //========================================================================
58 #if defined(__MINGW32__) && !defined(__WINPTHREADS_VERSION)
59 #include <string.h>
61 #define __rawmemchr strchr
63 char * strtok_r (char *s, const char *delim, char **save_ptr)
65 char *token;
67 if (s == NULL)
68 s = *save_ptr;
70 /* Scan leading delimiters. */
71 s += strspn (s, delim);
72 if (*s == '\0')
74 *save_ptr = s;
75 return NULL;
78 /* Find the end of the token. */
79 token = s;
80 s = strpbrk (token, delim);
81 if (s == NULL)
82 /* This token finishes the string. */
83 *save_ptr = __rawmemchr (token, '\0');
84 else
86 /* Terminate the token and make *SAVE_PTR point past it. */
87 *s = '\0';
88 *save_ptr = s + 1;
90 return token;
92 #endif