Mercurial > mplayer.hg
annotate osdep/strsep.c @ 30162:00c918779261
Add missing config.h #include; remove a redundant one.
author | diego |
---|---|
date | Mon, 04 Jan 2010 13:13:10 +0000 |
parents | 0f1b5b68af32 |
children | 7f7591482564 |
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" |
5393
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
25 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
26 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
|
27 char *begin, *end; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
28 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
29 begin = *stringp; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
30 if(begin == NULL) |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
31 return NULL; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
32 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
33 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
|
34 char ch = delim[0]; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
35 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
36 if(ch == '\0') |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
37 end = NULL; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
38 else { |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
39 if(*begin == ch) |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
40 end = begin; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
41 else if(*begin == '\0') |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
42 end = NULL; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
43 else |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
44 end = strchr(begin + 1, ch); |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
45 } |
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 else |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
48 end = strpbrk(begin, delim); |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
49 |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
50 if(end) { |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
51 *end++ = '\0'; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
52 *stringp = end; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
53 } |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
54 else |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
55 *stringp = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28744
diff
changeset
|
56 |
5393
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
57 return begin; |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
58 } |