FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/sprintf/strtok.c @ 982:461f7ee5f254
fc-olddump: brown paper bag
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Thu, 10 Dec 2015 05:35:42 +0000 |
parents | f8eaff87563f |
children |
rev | line source |
---|---|
825
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Copyright (c) 1985 Regents of the University of California. |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * All rights reserved. |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 * |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 * Redistribution and use in source and binary forms are permitted |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 * provided that the above copyright notice and this paragraph are |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 * duplicated in all such forms and that any documentation, |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 * advertising materials, and other materials related to such |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 * distribution and use acknowledge that the software was developed |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 * by the University of California, Berkeley. The name of the |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 * University may not be used to endorse or promote products derived |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 * from this software without specific prior written permission. |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 */ |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 #if defined(LIBC_SCCS) && !defined(lint) |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 static char sccsid[] = "@(#)strtok.c 5.4 (Berkeley) 6/27/88"; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 #endif /* LIBC_SCCS and not lint */ |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 char * |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 strtok(s, sep) |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 register char *s, *sep; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 { |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 register char *p; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 register c; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 static char *lasts; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 if (s == 0) |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 s = lasts; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 if (s == 0) |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 return (0); |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 while (c = *s) { |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 if (!index(sep, c)) |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 break; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 s++; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 } |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 if (c == '\0') { |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 lasts = 0; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 return (0); |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 } |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 for (p = s; c = *++p; ) |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 if (index(sep, c)) |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 break; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 if (c == '\0') |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 lasts = 0; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 else { |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 *p++ = '\0'; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 lasts = p; |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 } |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 return (s); |
f8eaff87563f
gsm-fw: replaced strtok() from newlib with 4.3BSD-Tahoe version
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 } |