Mercurial > trustbridge
comparison cinst/mozilla.c @ 909:18e3ad073b38
Use strtok_r/strtok_s instead of strtok.
With its global internal state usage of strtok should be
avoided.
Patch commited on behalf of Sascha Teichmann.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 14 Aug 2014 11:24:13 +0200 |
parents | 698b6a9bd75e |
children | 56ca8f2fd433 |
comparison
equal
deleted
inserted
replaced
908:d1c951b3012d | 909:18e3ad073b38 |
---|---|
89 * We use it for other other input puffers besides the IPC input, too. | 89 * We use it for other other input puffers besides the IPC input, too. |
90 * (One size fits all). | 90 * (One size fits all). |
91 */ | 91 */ |
92 #define LINEBUFLEN 10000 | 92 #define LINEBUFLEN 10000 |
93 | 93 |
94 #ifdef _WIN32 | |
95 #define STRTOK_R strtok_s | |
96 #else | |
97 #define STRTOK_R strtok_r | |
98 #endif | |
99 | |
94 /** | 100 /** |
95 * @brief Global Return Code | 101 * @brief Global Return Code |
96 * | 102 * |
97 * This will be retuned by the programm and might be set to an | 103 * This will be retuned by the programm and might be set to an |
98 * error code on fatal errors and to and warning code on non-fatal | 104 * error code on fatal errors and to and warning code on non-fatal |
161 char *value; | 167 char *value; |
162 char *path = NULL; | 168 char *path = NULL; |
163 char *fqpath; | 169 char *fqpath; |
164 bool inprofile = false; | 170 bool inprofile = false; |
165 bool relative_path = false; | 171 bool relative_path = false; |
172 char *saveptr; | |
166 | 173 |
167 if ((inifile = fopen(inifile_name, "r")) != NULL) | 174 if ((inifile = fopen(inifile_name, "r")) != NULL) |
168 { | 175 { |
169 DEBUGPRINTF("Searching for profile paths in: '%s'\n", inifile_name); | 176 DEBUGPRINTF("Searching for profile paths in: '%s'\n", inifile_name); |
170 | 177 |
181 inprofile = false; | 188 inprofile = false; |
182 | 189 |
183 /* If we are in a profile parse path related stuff */ | 190 /* If we are in a profile parse path related stuff */ |
184 if (inprofile) | 191 if (inprofile) |
185 { | 192 { |
186 key = strtok(line, "="); | 193 saveptr = NULL; |
187 value = strtok(NULL, "="); | 194 key = STRTOK_R(line, "=", &saveptr); |
195 value = STRTOK_R(NULL, "=", &saveptr); | |
188 str_trim(&value); | 196 str_trim(&value); |
189 if (str_equal(key, "Path")) | 197 if (str_equal(key, "Path")) |
190 { | 198 { |
191 if (relative_path) | 199 if (relative_path) |
192 xasprintf(&path, "%s/%s", inifile_dirname, value); | 200 xasprintf(&path, "%s/%s", inifile_dirname, value); |