From 417d917424618df5354619a6b8daff9a3f466dc1 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 1 Oct 2000 14:42:56 +0000 Subject: Minor fixes git-svn-id: http://svn.leocad.org/trunk@147 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- linux/profile.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/linux/profile.cpp b/linux/profile.cpp index e6d0482..b539704 100755 --- a/linux/profile.cpp +++ b/linux/profile.cpp @@ -121,8 +121,7 @@ static bool save_var (const char *section, const char *key, const char *value) fprintf (rc, "[%s]\n", section); } - fprintf (rc, "%s=%s\n", key, value); - + found = false; while (old_rc.ReadString (line, 1024) != NULL) { ptr = strchr (line, '='); @@ -132,16 +131,25 @@ static bool save_var (const char *section, const char *key, const char *value) *ptr = '\0'; if (strcmp (line, key) == 0) + { + fprintf (rc, "%s=%s\n", key, value); + found = true; break; - - *ptr = '='; - fputs (line, rc); + } + else + { + *ptr = '='; + fputs (line, rc); + } } else - { - fputs (line, rc); - break; - } + break; // reached end of section + } + + if (!found) + { + fprintf (rc, "%s=%s\n", key, value); + fputs ("\n", rc); } while (old_rc.ReadString (line, 1024) != NULL) -- cgit v1.2.3