Recent

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

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
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 »
keep it simple

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
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; ??
keep it simple

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
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)
keep it simple

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
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 »
keep it simple

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11448
  • FPC developer.
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: 4467
  • 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?
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11448
  • FPC developer.
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

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
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.
keep it simple

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
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
keep it simple

 

TinyPortal © 2005-2018