Mercurial > mplayer.hg
annotate osdep/strsep.c @ 36721:e9044aed2250
Fix issue with testing of the help message header files.
In order for all definitions to be checked properly, we cannot rely
on config.h, but must assure that all conditional symbolic constants
are defined.
author | ib |
---|---|
date | Sun, 09 Feb 2014 09:22:09 +0000 |
parents | c70109fc98b2 |
children |
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 <string.h> |
cbf0fed4d211
Add a configure test for the strsep function (it's missing on solaris)
jkeil
parents:
diff
changeset
|
22 |
16985 | 23 #include "config.h" |
30313
7f7591482564
Add a proper header for our strsep implementation so strsep will
reimar
parents:
29263
diff
changeset
|
24 #include "strsep.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 } |