Browse Source

* Fixed WriteString to be Windows/Delphi compatible. Writing an empty value does not delete the value

git-svn-id: trunk@17994 -
michael 14 years ago
parent
commit
066a001afe
1 changed files with 13 additions and 18 deletions
  1. 13 18
      packages/fcl-base/src/inifiles.pp

+ 13 - 18
packages/fcl-base/src/inifiles.pp

@@ -777,29 +777,24 @@ var
   oSection: TIniFileSection;
   oKey: TIniFileKey;
 begin
-  if (Section > '') and (Ident > '') then begin
+  if (Section > '') and (Ident > '') then 
+    begin
     // update or add key
     oSection := FSectionList.SectionByName(Section,CaseSensitive);
-    if (Value > '') then begin
-      if oSection = nil then begin
-        oSection := TIniFileSection.Create(Section);
-        FSectionList.Add(oSection);
-      end;
-      with oSection.KeyList do begin
-        oKey := KeyByName(Ident,CaseSensitive);
-        if oKey <> nil then
-          oKey.Value := Value
-        else
-          oSection.KeyList.Add(TIniFileKey.Create(Ident, Value));
+    if (oSection = nil) then 
+      begin
+      oSection := TIniFileSection.Create(Section);
+      FSectionList.Add(oSection);
       end;
-    end else if oSection <> nil then begin
-      // remove key
-      oKey := oSection.KeyList.KeyByName(Ident,CaseSensitive);
-      if oKey <> nil then begin
-        oSection.KeyList.Remove(oKey);
+    with oSection.KeyList do 
+      begin
+      oKey := KeyByName(Ident,CaseSensitive);
+      if oKey <> nil then
+        oKey.Value := Value
+      else
+        oSection.KeyList.Add(TIniFileKey.Create(Ident, Value));
       end;
     end;
-  end;
   MaybeUpdateFile;
 end;