annotate gui/util/string.c @ 34102:dd8320c2a2cb

libmpcodec: add vf_lavfi. This filter wraps a complete libavfilter filter graph. As the API of libavfilter is not completely stable yet, the filter is not enabled by default, so as not to let mplayer unbuildable. Some strange behaviours may appear due to the very different model of buffer allocation between mplayer and lavfi.
author cigaes
date Wed, 12 Oct 2011 11:38:10 +0000
parents d7527ee45784
children a345e7162d0a
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
33740
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
19 #include <stdio.h>
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
20 #include <stdlib.h>
33737
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
21 #include <string.h>
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
22
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
23 #include "string.h"
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
24
33982
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
25 /**
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
26 * @brief Convert a string to lower case.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
27 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
28 * @param string to be converted
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
29 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
30 * @return converted string
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
31 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
32 * @note Only characters from A to Z will be converted and this is an in-place conversion.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
33 */
33052
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
34 char *strlower(char *in)
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
35 {
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
36 char *p = in;
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
37
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
38 while (*p) {
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
39 if (*p >= 'A' && *p <= 'Z')
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
40 *p += 'a' - 'A';
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
41
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
42 p++;
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
43 }
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
44
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
45 return in;
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
46 }
956c67bb5198 Move strlower() into auxiliary string function file.
ib
parents: 33051
diff changeset
47
33982
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
48 /**
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
49 * @brief Swap characters in a string.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
50 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
51 * @param in string to be processed
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
52 * @param from character to be swapped
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
53 * @param to character to swap in
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
54 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
55 * @return processed string
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
56 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
57 * @note All occurrences will be swapped and this is an in-place processing.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
58 */
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
59 char *strswap(char *in, char from, char to)
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
60 {
33049
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
61 char *p = in;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
62
33049
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
63 while (*p) {
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
64 if (*p == from)
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
65 *p = to;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
66
33049
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
67 p++;
fc7a3f9f74f8 Simplify strswap().
ib
parents: 33048
diff changeset
68 }
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
69
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
70 return in;
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
71 }
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
72
33982
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
73 /**
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
74 * @brief Remove all space characters from a string,
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
75 * but leave text enclosed in quotation marks untouched.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
76 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
77 * @param in string to be processed
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
78 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
79 * @return processed string
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
80 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
81 * @note This is an in-place processing.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
82 */
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
83 char *trim(char *in)
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
84 {
33051
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
85 char *src, *dest;
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
86 int freeze = 0;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
87
33051
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
88 src = dest = in;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
89
33051
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
90 while (*src) {
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
91 if (*src == '"')
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
92 freeze = !freeze;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
93
33051
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
94 if (freeze || (*src != ' '))
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
95 *dest++ = *src;
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
96
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
97 src++;
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
98 }
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
99
33051
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
100 *dest = 0;
cec61c9f27f4 Simplify trim().
ib
parents: 33049
diff changeset
101
33048
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
102 return in;
c6d0adf896ea Move auxiliary string functions into separate file.
ib
parents:
diff changeset
103 }
33073
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
104
33982
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
105 /**
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
106 * @brief Remove a comment from a string,
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
107 * but leave text enclosed in quotation marks untouched.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
108 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
109 * A comment starts either with a semicolon anywhere in the string
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
110 * or with a number sign character at the very beginning.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
111 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
112 * @param in string to be processed
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
113 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
114 * @return string without comment
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
115 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
116 * @note This is an in-place processing, i.e. @a in will be shortened.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
117 */
33073
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
118 char *decomment(char *in)
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
119 {
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
120 char *p;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
121 int nap = 0;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
122
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
123 p = in;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
124
33080
60b2e408bd78 Allow number sign as comment character.
ib
parents: 33073
diff changeset
125 if (*p == '#')
60b2e408bd78 Allow number sign as comment character.
ib
parents: 33073
diff changeset
126 *p = 0;
60b2e408bd78 Allow number sign as comment character.
ib
parents: 33073
diff changeset
127
33073
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
128 while (*p) {
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
129 if (*p == '"')
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
130 nap = !nap;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
131
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
132 if ((*p == ';') && !nap) {
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
133 *p = 0;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
134 break;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
135 }
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
136
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
137 p++;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
138 }
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
139
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
140 return in;
334e19411421 Improve handling of the comment character.
ib
parents: 33052
diff changeset
141 }
33737
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
142
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
143 char *gstrchr(const char *str, int c)
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
144 {
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
145 if (!str)
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
146 return NULL;
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
147
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
148 return strchr(str, c);
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
149 }
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
150
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
151 int gstrcmp(const char *a, const char *b)
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
152 {
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
153 if (!a && !b)
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
154 return 0;
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
155 if (!a || !b)
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
156 return -1;
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
157
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
158 return strcmp(a, b);
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
159 }
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
160
33786
0d3d8db05a59 Compare encodings case insensitively.
ib
parents: 33740
diff changeset
161 int gstrcasecmp(const char *a, const char *b)
0d3d8db05a59 Compare encodings case insensitively.
ib
parents: 33740
diff changeset
162 {
0d3d8db05a59 Compare encodings case insensitively.
ib
parents: 33740
diff changeset
163 if (!a && !b)
0d3d8db05a59 Compare encodings case insensitively.
ib
parents: 33740
diff changeset
164 return 0;
0d3d8db05a59 Compare encodings case insensitively.
ib
parents: 33740
diff changeset
165 if (!a || !b)
0d3d8db05a59 Compare encodings case insensitively.
ib
parents: 33740
diff changeset
166 return -1;
0d3d8db05a59 Compare encodings case insensitively.
ib
parents: 33740
diff changeset
167
0d3d8db05a59 Compare encodings case insensitively.
ib
parents: 33740
diff changeset
168 return strcasecmp(a, b);
0d3d8db05a59 Compare encodings case insensitively.
ib
parents: 33740
diff changeset
169 }
0d3d8db05a59 Compare encodings case insensitively.
ib
parents: 33740
diff changeset
170
33737
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
171 int gstrncmp(const char *a, const char *b, int n)
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
172 {
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
173 if (!a && !b)
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
174 return 0;
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
175 if (!a || !b)
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
176 return -1;
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
177
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
178 return strncmp(a, b, n);
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
179 }
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
180
33982
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
181 /**
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
182 * @brief Duplicate a string.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
183 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
184 * If @a str is NULL, it returns NULL.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
185 * The string is duplicated by calling strdup().
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
186 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
187 * @param str string to be duplicated
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
188 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
189 * @return duplicated string (newly allocated)
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
190 */
33737
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
191 char *gstrdup(const char *str)
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
192 {
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
193 if (!str)
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
194 return NULL;
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
195
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
196 return strdup(str);
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33080
diff changeset
197 }
33740
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
198
33982
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
199 /**
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
200 * @brief Assign a duplicated string.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
201 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
202 * The string is duplicated by calling #gstrdup().
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
203 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
204 * @note @a *old is freed prior to the assignment.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
205 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
206 * @param old pointer to a variable suitable to store the new pointer
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
207 * @param str string to be duplicated
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
208 */
33740
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
209 void setdup(char **old, const char *str)
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
210 {
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
211 free(*old);
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
212 *old = gstrdup(str);
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
213 }
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
214
33982
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
215 /**
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
216 * @brief Assign a newly allocated string
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
217 * containing the path created from a directory and a filename.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
218 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
219 * @note @a *old is freed prior to the assignment.
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
220 *
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
221 * @param old pointer to a variable suitable to store the new pointer
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
222 * @param dir directory
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
223 * @param name filename
d7527ee45784 Add doxygen comments to string.c.
ib
parents: 33786
diff changeset
224 */
33740
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
225 void setddup(char **old, const char *dir, const char *name)
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
226 {
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
227 free(*old);
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
228 *old = malloc(strlen(dir) + strlen(name) + 2);
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
229 if (*old)
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
230 sprintf(*old, "%s/%s", dir, name);
2c02269701bd Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents: 33737
diff changeset
231 }