From b77f1217fb6b1bf34baa0da40de3ebf83c3c67c5 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 25 Jan 2007 06:49:22 +0000 Subject: Correct the spelling of persistent so its correct (Yes, I failed english at school). Loading a persistent setting again (from any config file, including config.cfg unless it has a ~) will remove it from the list of persistent settings. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12107 a1c6a512-1295-4272-9138-f99709370657 --- apps/settings.c | 65 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 16 deletions(-) (limited to 'apps') diff --git a/apps/settings.c b/apps/settings.c index 5dad1a4ff6..dcc3c8d9d2 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -259,19 +259,19 @@ static int hex_to_rgb(const char* hex) return 0; } #endif -#define MAX_PERSISTANT_VARS 8 -struct persistant_vars { +#define MAX_PERSISTENT_VARS 8 +struct persistent_vars { char setting[MAX_FILENAME]; char value[MAX_FILENAME]; }; -static struct persistant_vars persistant_vars[MAX_PERSISTANT_VARS]; -static int persistant_vars_count = 0; +static struct persistent_vars persistent_vars[MAX_PERSISTENT_VARS]; +static int persistent_vars_count = 0; bool settings_write_config(char* filename) { int i; int fd; - bool check_persistant = !strcmp(filename, CONFIGFILE) && - persistant_vars_count; + bool check_persistent = !strcmp(filename, CONFIGFILE) && + persistent_vars_count; char value[MAX_PATH]; fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY); if (fd < 0) @@ -282,16 +282,16 @@ bool settings_write_config(char* filename) { if (settings[i].cfg_name == NULL) continue; - if (check_persistant) + if (check_persistent) { int j; bool found = false; - for(j=0; jsetting)) + { + if (j+1 == persistent_vars_count) + { + /* simple case, just decrement + persistent_vars_count */ + persistent_vars_count--; + } + /*else move the last persistent var to here */ + else + { + strcpy(p_var->setting, p_var_last->setting); + strcpy(p_var->value, p_var_last->value); + persistent_vars_count--; + } + break; + } + } + } switch (settings[i].flags&F_T_MASK) { case F_T_INT: -- cgit v1.2.3