annotate osdep/strsep.c @ 31632:fc6f2b4e8a26

Avoid calling av_resample_init again when the values are the same as before. The init function can be called multiple times when e.g. additional format filters are inserted, so this speeds things up. Patch by Dan Oscarsson [Dan.Oscarsson tieto com].
author reimar
date Sun, 11 Jul 2010 09:46:58 +0000
parents 7f7591482564
children c70109fc98b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28744
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
1 /*
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
2 * strsep implementation for systems that do not have it in libc
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
3 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
4 * This file is part of MPlayer.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
5 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
7 * it under the terms of the GNU General Public License as published by
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
9 * (at your option) any later version.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
10 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
14 * GNU General Public License for more details.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
15 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
16 * You should have received a copy of the GNU General Public License along
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
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
08cac43f1e38 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9380
diff changeset
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 }