Forum > LCL

[SOLVED] Improvement of TFreeTypeFont.GetVersionNumber

(1/1)

lagprogramming:
components/freetype/easylazfreetype.pas has

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TFreeTypeFont.GetVersionNumber: string;var VersionStr: string;    idxStart,idxEnd: integer;begin  VersionStr := Information[ftiVersionString];  idxStart := 1;  while (idxStart < length(VersionStr)) and not (VersionStr[idxStart] in['0'..'9']) do    inc(idxStart);  idxEnd := idxStart;  while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);  if (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] = '.') then inc(idxEnd);  while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);  result := copy(VersionStr,idxStart,idxEnd-idxStart+1);end;
The attached patch replaces the occurencies of (idxEnd+1 <= length(VersionStr)) with (idxEnd < length(VersionStr)).

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---diff --git a/components/freetype/easylazfreetype.pas b/components/freetype/easylazfreetype.pasindex 9cf56731c0..27f7151674 100644--- a/components/freetype/easylazfreetype.pas+++ b/components/freetype/easylazfreetype.pas@@ -1143,9 +1143,9 @@ begin   while (idxStart < length(VersionStr)) and not (VersionStr[idxStart] in['0'..'9']) do     inc(idxStart);   idxEnd := idxStart;-  while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);-  if (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] = '.') then inc(idxEnd);-  while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);+  while (idxEnd < length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);+  if (idxEnd < length(VersionStr)) and (VersionStr[idxEnd+1] = '.') then inc(idxEnd);+  while (idxEnd < length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);   result := copy(VersionStr,idxStart,idxEnd-idxStart+1); end; 

AlexTP:
Posted to https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40438

Navigation

[0] Message Index

Go to full version