Browse Source

* Avoid that non-existing parts of version-numbers are replaced by zeros

git-svn-id: trunk@34144 -
joost 9 years ago
parent
commit
8e45ef394e
1 changed files with 22 additions and 7 deletions
  1. 22 7
      packages/fppkg/src/fpxmlrep.pp

+ 22 - 7
packages/fppkg/src/fpxmlrep.pp

@@ -214,10 +214,14 @@ begin
     If Not Assigned(Parent) then
       Parent:=XML;
     Parent.AppendChild(Result);
-    Result[SAttrMajor]:=IntToStr(V.Major);
-    Result[SAttrMinor]:=IntToStr(V.Minor);
+    if V.Major > -1 then
+      Result[SAttrMajor]:=IntToStr(V.Major);
+    if V.Minor > -1 then
+      Result[SAttrMinor]:=IntToStr(V.Minor);
+    if V.Micro > -1 then
     Result[SAttrMicro]:=IntToStr(V.Micro);
-    Result[SAttrBuild]:=IntToStr(V.Build);
+    if V.Build > -1 then
+      Result[SAttrBuild]:=IntToStr(V.Build);
   except
     Parent.RemoveChild(Result);
     Result.Free;
@@ -532,11 +536,22 @@ end;
 
 
 procedure TFPXMLRepositoryHandler.DoXMLToVersion(E: TDomElement; V: TFPVersion);
+
+  function ReadPart(AttrName: string): Integer;
+  var
+    i: Longint;
+  begin
+    if TryStrToInt(E[AttrName], i) then
+      Result := Abs(i)
+    else
+      Result := -1;
+  end;
+
 begin
-  V.Major:=Abs(StrToIntDef(E[SAttrMajor],0));
-  V.Minor:=Abs(StrToIntDef(E[SAttrMinor],0));
-  V.Micro:=Abs(StrToIntDef(E[SAttrMicro],0));
-  V.Build:=Abs(StrToIntDef(E[SAttrBuild],0));
+  V.Major := ReadPart(SAttrMajor);
+  V.Minor := ReadPart(SAttrMinor);
+  V.Micro := ReadPart(SAttrMicro);
+  V.Build := ReadPart(SAttrBuild);
 end;