annotate gui/util/string.c @ 33690:76342ee379eb

Add missing #include "libavutil/common.h".
author ib
date Wed, 29 Jun 2011 11:38:21 +0000
parents 60b2e408bd78
children 71c29e8ec68f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
1 /*
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
2 * This file is part of MPlayer.
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
3 *
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
7 * (at your option) any later version.
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
8 *
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
12 * GNU General Public License for more details.
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
13 *
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License along
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
17 */
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
18
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
19 #include "string.h"
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
20
33052
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
21 char *strlower(char *in)
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
22 {
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
23 char *p = in;
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
24
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
25 while (*p) {
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
26 if (*p >= 'A' && *p <= 'Z')
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
27 *p += 'a' - 'A';
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
28
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
29 p++;
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
30 }
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
31
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
32 return in;
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
33 }
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
34
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
35 char *strswap(char *in, char from, char to)
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
36 {
33049
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
37 char *p = in;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
38
33049
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
39 while (*p) {
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
40 if (*p == from)
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
41 *p = to;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
42
33049
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
43 p++;
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
44 }
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
45
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
46 return in;
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
47 }
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
48
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
49 char *trim(char *in)
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
50 {
33051
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
51 char *src, *dest;
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
52 int freeze = 0;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
53
33051
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
54 src = dest = in;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
55
33051
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
56 while (*src) {
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
57 if (*src == '"')
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
58 freeze = !freeze;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
59
33051
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
60 if (freeze || (*src != ' '))
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
61 *dest++ = *src;
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
62
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
63 src++;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
64 }
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
65
33051
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
66 *dest = 0;
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
67
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
68 return in;
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
69 }
33073
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
70
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
71 char *decomment(char *in)
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
72 {
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
73 char *p;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
74 int nap = 0;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
75
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
76 p = in;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
77
33080
60b2e408bd78 Allow number sign as comment character.
ib
parents: 33073
diff changeset
78 if (*p == '#')
60b2e408bd78 Allow number sign as comment character.
ib
parents: 33073
diff changeset
79 *p = 0;
60b2e408bd78 Allow number sign as comment character.
ib
parents: 33073
diff changeset
80
33073
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
81 while (*p) {
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
82 if (*p == '"')
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
83 nap = !nap;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
84
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
85 if ((*p == ';') && !nap) {
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
86 *p = 0;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
87 break;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
88 }
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
89
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
90 p++;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
91 }
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
92
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
93 return in;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
94 }