Mercurial > mplayer.hg
comparison gui/cfg.c @ 34621:97148652b0c6
Replace for loop with index by while loop with pointer.
author | ib |
---|---|
date | Mon, 13 Feb 2012 10:22:02 +0000 |
parents | 4ff933a89818 |
children | 73a5ecb53ee2 |
comparison
equal
deleted
inserted
replaced
34620:e3840eb107bc | 34621:97148652b0c6 |
---|---|
351 | 351 |
352 void cfg_write(void) | 352 void cfg_write(void) |
353 { | 353 { |
354 char *fname; | 354 char *fname; |
355 FILE *file; | 355 FILE *file; |
356 unsigned int i; | |
357 | 356 |
358 // configuration | 357 // configuration |
359 | 358 |
360 fname = get_path(gui_configuration); | 359 fname = get_path(gui_configuration); |
361 file = fopen(fname, "wt+"); | 360 file = fopen(fname, "wt+"); |
362 | 361 |
363 if (file) { | 362 if (file) { |
364 for (i = 0; gui_opts[i].name; i++) { | 363 const m_option_t *opts = gui_opts; |
365 char *val = m_option_print(&gui_opts[i], gui_opts[i].p); | 364 |
365 while (opts->name) { | |
366 char *val = m_option_print(opts, opts->p); | |
366 | 367 |
367 if (val == (char *)-1) { | 368 if (val == (char *)-1) { |
368 gmp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_UnableToSaveOption, gui_opts[i].name); | 369 gmp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_UnableToSaveOption, opts->name); |
369 val = NULL; | 370 val = NULL; |
370 } | 371 } |
371 | 372 |
372 if (val) { | 373 if (val) { |
373 char delim[] = "\""; | 374 char delim[] = "\""; |
374 | 375 |
375 if (!strchr(val, ' ')) | 376 if (!strchr(val, ' ')) |
376 *delim = 0; | 377 *delim = 0; |
377 | 378 |
378 fprintf(file, "%s=%s%s%s\n", gui_opts[i].name, delim, val, delim); | 379 fprintf(file, "%s=%s%s%s\n", opts->name, delim, val, delim); |
379 free(val); | 380 free(val); |
380 } | 381 } |
382 | |
383 opts++; | |
381 } | 384 } |
382 | 385 |
383 fclose(file); | 386 fclose(file); |
384 } | 387 } |
385 | 388 |
431 | 434 |
432 fname = get_path(gui_history); | 435 fname = get_path(gui_history); |
433 file = fopen(fname, "wt+"); | 436 file = fopen(fname, "wt+"); |
434 | 437 |
435 if (file) { | 438 if (file) { |
439 unsigned int i; | |
440 | |
436 for (i = 0; i < FF_ARRAY_ELEMS(fsHistory); i++) | 441 for (i = 0; i < FF_ARRAY_ELEMS(fsHistory); i++) |
437 if (fsHistory[i]) | 442 if (fsHistory[i]) |
438 fprintf(file, "%s\n", fsHistory[i]); | 443 fprintf(file, "%s\n", fsHistory[i]); |
439 | 444 |
440 fclose(file); | 445 fclose(file); |