summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)