doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
strtok.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at http://curl.haxx.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  * $Id: strtok.c,v 1.13 2004/01/29 13:56:45 bagder Exp $
22  ***************************************************************************/
23 
24 #include "setup.h"
25 
26 #ifndef HAVE_STRTOK_R
27 #include <stddef.h>
28 #include <string.h>
29 
30 #include "strtok.h"
31 
32 char *
33 Curl_strtok_r(char *ptr, const char *sep, char **end)
34 {
35  if (!ptr)
36  /* we got NULL input so then we get our last position instead */
37  ptr = *end;
38 
39  /* pass all letters that are including in the separator string */
40  while (*ptr && strchr(sep, *ptr))
41  ++ptr;
42 
43  if (*ptr) {
44  /* so this is where the next piece of string starts */
45  char *start = ptr;
46 
47  /* set the end pointer to the first byte after the start */
48  *end = start + 1;
49 
50  /* scan through the string to find where it ends, it ends on a
51  null byte or a character that exists in the separator string */
52  while (**end && !strchr(sep, **end))
53  ++*end;
54 
55  if (**end) {
56  /* the end is not a null byte */
57  **end = '\0'; /* zero terminate it! */
58  ++*end; /* advance the last pointer to beyond the null byte */
59  }
60 
61  return start; /* return the position where the string starts */
62  }
63 
64  /* we ended up on a null byte, there are no more strings to find! */
65  return NULL;
66 }
67 
68 #endif /* this was only compiled if strtok_r wasn't present */
char * Curl_strtok_r(char *ptr, const char *sep, char **end)
Definition: strtok.c:33
GLuint GLuint end
Definition: glext.h:2845
#define NULL
Definition: Lib.h:88
GLuint start
Definition: glext.h:2845