Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/curl/lib/strtok.c @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /*************************************************************************** | |
| 2 * _ _ ____ _ | |
| 3 * Project ___| | | | _ \| | | |
| 4 * / __| | | | |_) | | | |
| 5 * | (__| |_| | _ <| |___ | |
| 6 * \___|\___/|_| \_\_____| | |
| 7 * | |
| 8 * Copyright (C) 1998 - 2007, 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 https://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 ***************************************************************************/ | |
| 22 | |
| 23 #include "curl_setup.h" | |
| 24 | |
| 25 #ifndef HAVE_STRTOK_R | |
| 26 #include <stddef.h> | |
| 27 | |
| 28 #include "strtok.h" | |
| 29 | |
| 30 char * | |
| 31 Curl_strtok_r(char *ptr, const char *sep, char **end) | |
| 32 { | |
| 33 if(!ptr) | |
| 34 /* we got NULL input so then we get our last position instead */ | |
| 35 ptr = *end; | |
| 36 | |
| 37 /* pass all letters that are including in the separator string */ | |
| 38 while(*ptr && strchr(sep, *ptr)) | |
| 39 ++ptr; | |
| 40 | |
| 41 if(*ptr) { | |
| 42 /* so this is where the next piece of string starts */ | |
| 43 char *start = ptr; | |
| 44 | |
| 45 /* set the end pointer to the first byte after the start */ | |
| 46 *end = start + 1; | |
| 47 | |
| 48 /* scan through the string to find where it ends, it ends on a | |
| 49 null byte or a character that exists in the separator string */ | |
| 50 while(**end && !strchr(sep, **end)) | |
| 51 ++*end; | |
| 52 | |
| 53 if(**end) { | |
| 54 /* the end is not a null byte */ | |
| 55 **end = '\0'; /* zero terminate it! */ | |
| 56 ++*end; /* advance the last pointer to beyond the null byte */ | |
| 57 } | |
| 58 | |
| 59 return start; /* return the position where the string starts */ | |
| 60 } | |
| 61 | |
| 62 /* we ended up on a null byte, there are no more strings to find! */ | |
| 63 return NULL; | |
| 64 } | |
| 65 | |
| 66 #endif /* this was only compiled if strtok_r wasn't present */ |
