summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorleo2000-10-01 14:42:56 +0000
committerleo2000-10-01 14:42:56 +0000
commit417d917424618df5354619a6b8daff9a3f466dc1 (patch)
tree37d89206533a281ebe2f56d9785176fa3f9e12ed /linux
parent9dd10e510c37b137ded7215d3db12e5066409335 (diff)
Minor fixes
git-svn-id: http://svn.leocad.org/trunk@147 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'linux')
-rwxr-xr-xlinux/profile.cpp26
1 files 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)