* Patch from Darius Blaszijk to support version numbers with less then three digits, bug #17833

git-svn-id: trunk@16484 -
This commit is contained in:
joost 2010-11-30 13:51:01 +00:00
parent 4ed666afab
commit 191e83cb7e

View File

@ -259,7 +259,7 @@ Type
FMajor, FMajor,
FMinor, FMinor,
FMicro, FMicro,
FBuild : Word; FBuild : Integer;
function GetAsString: String; function GetAsString: String;
function GetEmpty: Boolean; function GetEmpty: Boolean;
procedure SetAsString(const AValue: String); procedure SetAsString(const AValue: String);
@ -271,10 +271,10 @@ Type
Property AsString : String Read GetAsString Write SetAsString; Property AsString : String Read GetAsString Write SetAsString;
Property Empty : Boolean Read GetEmpty; Property Empty : Boolean Read GetEmpty;
Published Published
Property Major : Word Read FMajor Write FMajor; Property Major : Integer Read FMajor Write FMajor;
Property Minor : Word Read FMinor Write FMinor; Property Minor : Integer Read FMinor Write FMinor;
Property Micro : Word Read FMicro Write FMicro; Property Micro : Integer Read FMicro Write FMicro;
Property Build : Word Read FBuild Write FBuild; Property Build : Integer Read FBuild Write FBuild;
end; end;
{ TConditionalString } { TConditionalString }
@ -2330,6 +2330,21 @@ Procedure TPackage.GetManifest(Manifest : TStrings);
Manifest.Add(AIndent+'</cpus>'); Manifest.Add(AIndent+'</cpus>');
end; end;
function GetXMLVersionString(sMajor, sMinor, sMicro, sBuild: integer): string;
begin
Result := '<version';
if sMajor <> -1 then
Result := Result + ' major="' + IntToStr(sMajor) + '"';
if sMinor <> -1 then
Result := Result + ' minor="' + IntToStr(sMinor) + '"';
if sMicro <> -1 then
Result := Result + ' micro="' + IntToStr(sMicro) + '"';
if sBuild <> -1 then
Result := Result + ' build="' + IntToStr(sBuild) + '"';
Result := Result + '/>';
end;
Var Var
S : String; S : String;
i : Integer; i : Integer;
@ -2338,7 +2353,8 @@ begin
With Manifest do With Manifest do
begin begin
Add(Format('<package name="%s">',[QuoteXml(Name)])); Add(Format('<package name="%s">',[QuoteXml(Name)]));
Add(Format(' <version major="%d" minor="%d" micro="%d" build="%d"/>',[FVersion.Major,FVersion.Minor,FVersion.Micro,FVersion.Build]));
Add(' ' + GetXMLVersionString(FVersion.Major,FVersion.Minor,FVersion.Micro,FVersion.Build));
AddOSes(' ',OSes); AddOSes(' ',OSes);
AddCPUs(' ',CPUs); AddCPUs(' ',CPUs);
Add(Format(' <filename>%s</filename>',[QuoteXml(FileName + ZipExt)])); Add(Format(' <filename>%s</filename>',[QuoteXml(FileName + ZipExt)]));
@ -2361,7 +2377,7 @@ begin
Add(' <dependency>'); Add(' <dependency>');
Add(Format(' <package packagename="%s"/>',[QuoteXML(D.Value)])); Add(Format(' <package packagename="%s"/>',[QuoteXML(D.Value)]));
if not D.FVersion.Empty then if not D.FVersion.Empty then
Add(Format(' <version major="%d" minor="%d" micro="%d" build="%d"/>',[D.FVersion.Major,D.FVersion.Minor,D.FVersion.Micro,D.FVersion.Build])); Add(' ' + GetXMLVersionString(D.FVersion.Major,D.FVersion.Minor,D.FVersion.Micro,D.FVersion.Build));
AddOSes(' ',D.OSes); AddOSes(' ',D.OSes);
AddCPUs(' ',D.CPUs); AddCPUs(' ',D.CPUs);
Add(' </dependency>'); Add(' </dependency>');
@ -4856,7 +4872,17 @@ begin
if Empty then if Empty then
Result:='<none>' Result:='<none>'
else else
Result:=Format('%d.%d.%d-%d',[Major,Minor,Micro,Build]); begin
Result := '';
if Major <> -1 then
Result := Result + IntToStr(Major);
if Minor <> -1 then
Result := Result + '.' + IntToStr(Minor);
if Micro <> -1 then
Result := Result + '.' + IntToStr(Micro);
if Build <> -1 then
Result := Result + '-' + IntToStr(Build);
end;
end; end;
function TFPVersion.GetEmpty: Boolean; function TFPVersion.GetEmpty: Boolean;
@ -4867,19 +4893,15 @@ end;
procedure TFPVersion.SetAsString(const AValue: String); procedure TFPVersion.SetAsString(const AValue: String);
Function NextDigit(sep : Char; var V : string) : integer; Function NextDigit(sep : Char; var V : string) : integer;
Var Var
P : Integer; P : Integer;
begin begin
P:=Pos(Sep,V); P:=Pos(Sep,V);
If (P=0) then If (P=0) then
P:=Length(V)+1; P:=Length(V)+1;
Result:=StrToIntDef(Copy(V,1,P-1),-1); Result:=StrToIntDef(Copy(V,1,P-1),-1);
If Result<>-1 then If Result<>-1 then
Delete(V,1,P) Delete(V,1,P);
else
Result:=0;
end; end;
Var Var
@ -4898,17 +4920,15 @@ end;
procedure TFPVersion.Clear; procedure TFPVersion.Clear;
begin begin
Micro:=0; Micro:=-1;
Major:=0; Major:=-1;
Minor:=0; Minor:=-1;
Build:=0; Build:=-1;
end; end;
procedure TFPVersion.Assign(Source: TPersistent); procedure TFPVersion.Assign(Source: TPersistent);
Var Var
V : TFPVersion; V : TFPVersion;
begin begin
if Source is TFPVersion then if Source is TFPVersion then
begin begin