|
|
1.1 root 1: /******************************************************************************
2: * Copyright (c) 2004, 2008 IBM Corporation
3: * All rights reserved.
4: * This program and the accompanying materials
5: * are made available under the terms of the BSD License
6: * which accompanies this distribution, and is available at
7: * http://www.opensource.org/licenses/bsd-license.php
8: *
9: * Contributors:
10: * IBM Corporation - initial implementation
11: *****************************************************************************/
12:
13: #include <string.h>
14:
15: char *
16: strtok(char *src, const char *pattern)
17: {
18: static char *nxtTok;
19: char *retVal = NULL;
20:
21: if (!src)
22: src = nxtTok;
23:
24: while (*src) {
25: const char *pp = pattern;
26: while (*pp) {
27: if (*pp == *src) {
28: break;
29: }
30: pp++;
31: }
32: if (!*pp) {
33: if (!retVal)
34: retVal = src;
35: else if (!src[-1])
36: break;
37: } else
38: *src = '\0';
39: src++;
40: }
41:
42: nxtTok = src;
43:
44: return retVal;
45: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.