Skip to content

Commit fc43086

Browse files
committed
Changed CompareVersions to make it "Delphi compare" like.
1 parent 2c44645 commit fc43086

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

PythonForDelphi/Components/Sources/Core/PythonVersions.pas

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ TPythonVersion = record
4343

4444
TPythonVersions = array of TPythonVersion;
4545

46-
(* Compares two Version strings and returns -1, 0, 1 depending on result *)
46+
(*
47+
Compares two Version strings and returns -1, 0, 1 depending on result
48+
The function result has the semantics of Delphi compare functions
49+
-1: A is bigger (newer), 0: equal versions, 1: B is bigger (newer)
50+
*)
4751
function CompareVersions(A, B : String) : Integer;
4852

4953

@@ -206,7 +210,7 @@ function GetRegisterPythonVersion(SysVersion: string;
206210
RootKey := Root;
207211
if OpenKey(Key + '\InstallPath', False) then begin
208212
PythonVersion.InstallPath := ReadString('');
209-
if PythonVersion.IsAllUsers and (CompareVersions(SysVersion, '3.5') < 0) then
213+
if PythonVersion.IsAllUsers and (CompareVersions(SysVersion, '3.5') > 0) then
210214
PythonVersion.DLLPath := ''
211215
else
212216
PythonVersion.DLLPath := PythonVersion.InstallPath;
@@ -246,7 +250,7 @@ function GetRegisterPythonVersion(SysVersion: string;
246250

247251
VersionSuffix := '';
248252
{$IFDEF CPUX86}
249-
if CompareVersions(SysVersion, '3.5') >= 0 then
253+
if CompareVersions(SysVersion, '3.5') <= 0 then
250254
VersionSuffix := '-32';
251255
{$ENDIF}
252256
key := Format('\Software\Python\PythonCore\%s%s', [SysVersion, VersionSuffix]);

0 commit comments

Comments
 (0)