changeset 34621:97148652b0c6

Replace for loop with index by while loop with pointer.
author ib
date Mon, 13 Feb 2012 10:22:02 +0000
parents e3840eb107bc
children e96ee4cac59f
files gui/cfg.c
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/gui/cfg.c	Mon Feb 13 09:09:02 2012 +0000
+++ b/gui/cfg.c	Mon Feb 13 10:22:02 2012 +0000
@@ -353,7 +353,6 @@
 {
     char *fname;
     FILE *file;
-    unsigned int i;
 
     // configuration
 
@@ -361,11 +360,13 @@
     file  = fopen(fname, "wt+");
 
     if (file) {
-        for (i = 0; gui_opts[i].name; i++) {
-            char *val = m_option_print(&gui_opts[i], gui_opts[i].p);
+        const m_option_t *opts = gui_opts;
+
+        while (opts->name) {
+            char *val = m_option_print(opts, opts->p);
 
             if (val == (char *)-1) {
-                gmp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_UnableToSaveOption, gui_opts[i].name);
+                gmp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_UnableToSaveOption, opts->name);
                 val = NULL;
             }
 
@@ -375,9 +376,11 @@
                 if (!strchr(val, ' '))
                     *delim = 0;
 
-                fprintf(file, "%s=%s%s%s\n", gui_opts[i].name, delim, val, delim);
+                fprintf(file, "%s=%s%s%s\n", opts->name, delim, val, delim);
                 free(val);
             }
+
+            opts++;
         }
 
         fclose(file);
@@ -433,6 +436,8 @@
     file  = fopen(fname, "wt+");
 
     if (file) {
+        unsigned int i;
+
         for (i = 0; i < FF_ARRAY_ELEMS(fsHistory); i++)
             if (fsHistory[i])
                 fprintf(file, "%s\n", fsHistory[i]);