View Issue Details

IDProjectCategoryView StatusLast Update
0038514FPCCompilerpublic2021-02-21 19:04
ReporterAlfred Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0038514: CompareVersionStrings gives wrong result when comparing two identical versions.
DescriptionCompareVersionStrings from cutils.pas seems to give a wrong result when comparing two identical version strings.

v1:='3.3.1';
v2:='3.3.1';
CompareVersionStrings (v1,v2) should be zero, but produces a 1.

Probable cause:
    { if one of the two is at the end while the other isn't, add a '.0' }
    if (i1>length(s1)) and
       (i2<=length(s2)) then
      s1:=s1+'.0'
    else if i2>length(s2) then
      s2:=s2+'.0';

Should be:
    { if one of the two is at the end while the other isn't, add a '.0' }
    if (i1>length(s1)) and
       (i2<=length(s2)) then
      s1:=s1+'.0';
    if (i2>length(s2)) and
       (i1<=length(s1)) then
       s2:=s2+'.0';

So, test for extension of s1 and/or s2 is now identical.
TagsNo tags attached.
Fixed in Revision48757
FPCOldBugId
FPCTarget-
Attached Files

Activities

Do-wan Kim

2021-02-20 03:26

reporter   ~0129026

Good catch.
38514_cutils.pas.patch (627 bytes)   
Index: compiler/cutils.pas
===================================================================
--- compiler/cutils.pas	(revision 48730)
+++ compiler/cutils.pas	(working copy)
@@ -1298,8 +1298,9 @@
           { if one of the two is at the end while the other isn't, add a '.0' }
           if (i1>length(s1)) and
              (i2<=length(s2)) then
-            s1:=s1+'.0'
-          else if i2>length(s2) then
+            s1:=s1+'.0';
+          if (i2>length(s2)) and
+		     (i1<=length(s1)) then
             s2:=s2+'.0';
           { compare non-numerical characters normally }
           while (i1<=length(s1)) and
38514_cutils.pas.patch (627 bytes)   

Florian

2021-02-21 19:04

administrator   ~0129068

Thanks, fixed.

Issue History

Date Modified Username Field Change
2021-02-19 09:36 Alfred New Issue
2021-02-20 03:26 Do-wan Kim Note Added: 0129026
2021-02-20 03:26 Do-wan Kim File Added: 38514_cutils.pas.patch
2021-02-21 19:04 Florian Assigned To => Florian
2021-02-21 19:04 Florian Status new => resolved
2021-02-21 19:04 Florian Resolution open => fixed
2021-02-21 19:04 Florian Fixed in Version => 3.3.1
2021-02-21 19:04 Florian Fixed in Revision => 48757
2021-02-21 19:04 Florian FPCTarget => -
2021-02-21 19:04 Florian Note Added: 0129068