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