| OLD | NEW |
| (Empty) |
| 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | |
| 2 /* This Source Code Form is subject to the terms of the Mozilla Public | |
| 3 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
| 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
| 5 | |
| 6 #include "plstr.h" | |
| 7 | |
| 8 PR_IMPLEMENT(char *) | |
| 9 PL_strtok_r(char *s1, const char *s2, char **lasts) | |
| 10 { | |
| 11 const char *sepp; | |
| 12 int c, sc; | |
| 13 char *tok; | |
| 14 | |
| 15 if( s1 == NULL ) | |
| 16 { | |
| 17 if( *lasts == NULL ) | |
| 18 return NULL; | |
| 19 | |
| 20 s1 = *lasts; | |
| 21 } | |
| 22 | |
| 23 for( ; (c = *s1) != 0; s1++ ) | |
| 24 { | |
| 25 for( sepp = s2 ; (sc = *sepp) != 0 ; sepp++ ) | |
| 26 { | |
| 27 if( c == sc ) | |
| 28 break; | |
| 29 } | |
| 30 if( sc == 0 ) | |
| 31 break; | |
| 32 } | |
| 33 | |
| 34 if( c == 0 ) | |
| 35 { | |
| 36 *lasts = NULL; | |
| 37 return NULL; | |
| 38 } | |
| 39 | |
| 40 tok = s1++; | |
| 41 | |
| 42 for( ; (c = *s1) != 0; s1++ ) | |
| 43 { | |
| 44 for( sepp = s2; (sc = *sepp) != 0; sepp++ ) | |
| 45 { | |
| 46 if( c == sc ) | |
| 47 { | |
| 48 *s1++ = '\0'; | |
| 49 *lasts = s1; | |
| 50 return tok; | |
| 51 } | |
| 52 } | |
| 53 } | |
| 54 *lasts = NULL; | |
| 55 return tok; | |
| 56 } | |
| OLD | NEW |