Mercurial > mplayer.hg
annotate osdep/strsep.c @ 32502:9705236ce079
Change code to something understandable (but equivalent).
author | reimar |
---|---|
date | Sat, 06 Nov 2010 19:33:30 +0000 |
parents | 7f7591482564 |
children | c70109fc98b2 |
rev | line source |
---|---|
28744 | 1 /* |
2 * strsep implementation for systems that do not have it in libc | |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
5393
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
20 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
21 #include <stdio.h> |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
22 #include <string.h> |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
23 |
16985 | 24 #include "config.h" |
30313
7f7591482564
Add a proper header for our strsep implementation so strsep will
reimar
parents:
29263
diff
changeset
|
25 #include "strsep.h" |
5393
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
26 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
27 char *strsep(char **stringp, const char *delim) { |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
28 char *begin, *end; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
29 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
30 begin = *stringp; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
31 if(begin == NULL) |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
32 return NULL; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
33 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
34 if(delim[0] == '\0' || delim[1] == '\0') { |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
35 char ch = delim[0]; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
36 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
37 if(ch == '\0') |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
38 end = NULL; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
39 else { |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
40 if(*begin == ch) |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
41 end = begin; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
42 else if(*begin == '\0') |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
43 end = NULL; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
44 else |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
45 end = strchr(begin + 1, ch); |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
46 } |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
47 } |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
48 else |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
49 end = strpbrk(begin, delim); |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
50 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
51 if(end) { |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
52 *end++ = '\0'; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
53 *stringp = end; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
54 } |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
55 else |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
56 *stringp = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28744
diff
changeset
|
57 |
5393
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
58 return begin; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
59 } |