* * *

Author Topic: Redundancy / Errors in lazutf8.pas  (Read 465 times)

Munair

  • Sr. Member
  • ****
  • Posts: 303
  • Keep it simple.
    • Ditrianum
Redundancy / Errors in lazutf8.pas
« on: December 07, 2017, 01:19:39 pm »
While going over the lazutf8.pas file, I noticed some redundancy and errors. See also the next posts. Here is the first piece:
Code: Pascal  [Select]
  1. ...else if (c2 = #$84) and (c3 = #$AA) then
  2.         begin
  3.           inc(InStr, 3);
  4.           if c3 = #$AA then OutStr^ := #$6B
  5.           else OutStr^ := #$E5;
  6.           inc(OutStr);
  7.           inc(CounterDiff, 2);
  8.           Continue;
  9.         end
Here c3 is tested twice for the same value. so it looks like "OutStr^ := #$E5" will never happen...
See lines 2107 to 2115: https://github.com/alrieckert/lazarus/blob/master/components/lazutils/lazutf8.pas
« Last Edit: December 07, 2017, 04:18:02 pm by Munair »
Lazarus 1.6.2, testing 1.8, FPC 3.0.0; Debian 9 KDE 5.8.6 x64; Windows 7 x64, PC-DOS2000

Munair

  • Sr. Member
  • ****
  • Posts: 303
  • Keep it simple.
    • Ditrianum
Re: Redundant code in lazutf8.pas
« Reply #1 on: December 07, 2017, 01:34:54 pm »
Another inconsistency:
Code: Pascal  [Select]
  1. else if (c2 = #$92) and (c3 in [#$B6..#$BF]) then
  2.         begin
  3.           new_c3 := #$93;
  4.           new_c3 := chr(ord(c3) - $26);
  5.         end
at lines 2158 to 2161. Should that be:  new_c2 := #$93; ??
Lazarus 1.6.2, testing 1.8, FPC 3.0.0; Debian 9 KDE 5.8.6 x64; Windows 7 x64, PC-DOS2000

Munair

  • Sr. Member
  • ****
  • Posts: 303
  • Keep it simple.
    • Ditrianum
Re: Redundancy / Errors in lazutf8.pas
« Reply #2 on: December 07, 2017, 01:41:18 pm »
Line 2162:
Code: Pascal  [Select]
  1. else if (c2 = #$93) and (c3 in [#$80..#$8F]) then new_c3 := chr(ord(c3) + 26)
should be (?):
Code: Pascal  [Select]
  1. else if (c2 = #$93) and (c3 in [#$80..#$8F]) then new_c3 := chr(ord(c3) + $26)
Lazarus 1.6.2, testing 1.8, FPC 3.0.0; Debian 9 KDE 5.8.6 x64; Windows 7 x64, PC-DOS2000

Munair

  • Sr. Member
  • ****
  • Posts: 303
  • Keep it simple.
    • Ditrianum
Re: Redundancy / Errors in lazutf8.pas
« Reply #3 on: December 07, 2017, 03:51:32 pm »
Another piece:
Code: Pascal  [Select]
  1. begin
  2.             inc(InStr, 3);
  3.             case c3 of
  4.             #$BE: OutStr^ := #$C8;
  5.             #$BF: OutStr^ := #$C9;
  6.             end;
  7. // ???:
  8.             OutStr^ := #$C8;
  9.             inc(OutStr);
  10.             case c3 of
  11.             #$BE: OutStr^ := #$BF;
  12.             #$BF: OutStr^ := #$80;
  13.             end;
  14.             inc(OutStr);
  15.             inc(CounterDiff, 1);
  16.             Continue;
  17.           end;
from line 2244 to line 2259.

A wild guess is that the first case block is redundant.
« Last Edit: December 07, 2017, 03:54:46 pm by Munair »
Lazarus 1.6.2, testing 1.8, FPC 3.0.0; Debian 9 KDE 5.8.6 x64; Windows 7 x64, PC-DOS2000

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5875
Re: Redundancy / Errors in lazutf8.pas
« Reply #4 on: December 07, 2017, 04:52:14 pm »
Seems that github fork of the core SVN repository is not in sync. I see at least 6 more commits after the version mentioned on by Juha in March.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3262
  • I like bugs.
Re: Redundancy / Errors in lazutf8.pas
« Reply #5 on: December 07, 2017, 05:12:55 pm »
Munair, I applied your findings except the last one in r56662. The last one may be right although I don't know the code well.

Seems that github fork of the core SVN repository is not in sync.
Yes, the "alrieckert" GitHub fork stopped synchronizing when SVN URL got the secure "https:" connection.
I also had to clone again my local git-svn link repo then.
Does "alrieckert" know about the issue?

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5875
Re: Redundancy / Errors in lazutf8.pas
« Reply #6 on: December 07, 2017, 05:54:26 pm »
I don't know the status of the various branches, I don't use git(hub) very actively.

Munair

  • Sr. Member
  • ****
  • Posts: 303
  • Keep it simple.
    • Ditrianum
Re: Redundancy / Errors in lazutf8.pas
« Reply #7 on: December 07, 2017, 09:27:16 pm »
I wasn't aware of the different versions.  :D  Anyway, I turned at the one shipped with 1.8.
Lazarus 1.6.2, testing 1.8, FPC 3.0.0; Debian 9 KDE 5.8.6 x64; Windows 7 x64, PC-DOS2000

Munair

  • Sr. Member
  • ****
  • Posts: 303
  • Keep it simple.
    • Ditrianum
Re: Redundancy / Errors in lazutf8.pas
« Reply #8 on: December 11, 2017, 09:00:42 pm »
I posted another bug in the section General today with a possible solution (that I applied in the FreeBasic version): http://forum.lazarus.freepascal.org/index.php/topic,39260.0.html
Lazarus 1.6.2, testing 1.8, FPC 3.0.0; Debian 9 KDE 5.8.6 x64; Windows 7 x64, PC-DOS2000

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus