summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/apps/settings.c b/apps/settings.c
index c7794e1015..1a7d159666 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -262,7 +262,7 @@ bool settings_write_config(char* filename)
262{ 262{
263 int i; 263 int i;
264 int fd; 264 int fd;
265 char value[MAX_PATH]; 265 char value[MAX_FILENAME * 3]; /* More than enough for all current values */
266 fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY); 266 fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY);
267 if (fd < 0) 267 if (fd < 0)
268 return false; 268 return false;
@@ -287,27 +287,38 @@ bool settings_write_config(char* filename)
287 } 287 }
288 else 288 else
289#endif 289#endif
290 if (settings[i].cfg_vals == NULL) 290 if (settings[i].cfg_vals == NULL)
291 { 291 {
292 snprintf(value,MAX_PATH,"%d",*(int*)settings[i].setting); 292 snprintf(value,MAX_PATH,"%d",*(int*)settings[i].setting);
293 } 293 }
294 else 294 else
295 { 295 {
296 char *s,*end; 296 const char *s;
297 char vals[MAX_PATH]; 297 const char *end;
298 int val = 0; 298 int val = 0;
299 strncpy(vals,settings[i].cfg_vals,MAX_PATH); 299
300 s = strtok_r(vals,",",&end); 300 end = s = settings[i].cfg_vals;
301 while (s) 301
302 do
302 { 303 {
304 while (*end != 0 && *end != ',')
305 {
306 end++;
307 }
308
303 if (val == *(int*)settings[i].setting) 309 if (val == *(int*)settings[i].setting)
304 { 310 {
305 strncpy(value,s,MAX_PATH); 311 strncpy(value, s, end - s);
312 value[end - s] = 0;
306 break; 313 break;
307 } 314 }
308 val++; 315 else
309 s = strtok_r(NULL,",",&end); 316 {
317 s = end + 1;
318 val++;
319 }
310 } 320 }
321 while (*end++);
311 } 322 }
312 break; 323 break;
313 case F_T_BOOL: 324 case F_T_BOOL: