[patch_done] Loockup error

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
Shagrat3
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 28.07.2009, 16:02
Contact:

[patch_done] Loockup error

Post by Shagrat3 »

I found bag:
Found unneeded code lines for WideString
You do not have the required permissions to view the files attached to this post.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

Shagrat3,

i don't understand, why these lines are not needed.

I think the whole code is this:

Code: Select all

    if PartialKey then
    begin
      if CurrentType = stUnicodeString then
      begin
        WValue1 := KeyValues[I].VUnicodeString;
        WValue2 := ResultSet.GetUnicodeString(ColumnIndex);

        if CaseInsensitive then
          WValue2 := WideUpperCase(WValue2);
        {$IFDEF DELPHI12_UP}
        Result := SysUtils.AnsiStrLComp(PWideChar(WValue2), PWideChar(WValue1), Length(WValue1)) = 0;
        {$ELSE}
          AValue1 := UTF8ToAnsi(UTF8Encode(WValue1));
          AValue2 := UTF8ToAnsi(UTF8Encode(WValue2));
          Result := AnsiStrLComp(PAnsiChar(AValue2), PAnsiChar(AValue1), Length(AValue1)) = 0;
        {$ENDIF}
      end
      else //-> AnsiStringData or other string-compatible data-fields
      begin
        AValue1 := AnsiString(KeyValues[I].VString);
        AValue2 := AnsiString(ResultSet.GetString(ColumnIndex));

        if CaseInsensitive then
          {$IFDEF LAZARUSUTF8HACK}
          AValue2 := AnsiUpperCase(Utf8ToAnsi(AValue2));
          {$ELSE}
          AValue2 := {$IFDEF DELPHI12_UP}AnsiStrings.{$ENDIF}AnsiUpperCase(AValue2);
          {$ENDIF}
        Result := AnsiStrLComp(PAnsiChar(AValue2), PAnsiChar(AValue1), Length(AValue1)) = 0;
      end;
Which means we do also compare nun Unicode-Fields. In my branch both (stUnicodeString/stString) types are valid. stString is for Ansi-Connection or Fields which have a static mask like type 'Mac' or 'IP' of PostgresSQL. stUnicodeString is for unicode Connections and means a UTF8Decoded Wide/UnicodeString.

So please try to teach me, why these lines are waste.
Your toppic also points me to an error. Do you realy have one? Has something changed?

Michael
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Shagrat3
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 28.07.2009, 16:02
Contact:

Post by Shagrat3 »

In picture has:

Code: Select all

if CaseInsensitive then
        {$IFDEF LAZARUSUTF8HACK}
        AValue2 := AnsiUpperCase(Utf8ToAnsi(AValue2));
        {$ELSE}
        AValue2 := {$IFDEF DELPHI12_UP}AnsiStrings.{$ENDIF}AnsiUpperCase(AValue2);
        {$ENDIF}
      Result := AnsiStrLComp(PAnsiChar(AValue2), PAnsiChar(AValue1), Length(AValue1)) = 0;
     end;
The unnecessary part of the code corrupts the correct comparison WideString
You do not have the required permissions to view the files attached to this post.
Shagrat3
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 28.07.2009, 16:02
Contact:

Post by Shagrat3 »

User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

Shagrat3,

you're right! Wondering why these lines are still available. I had removed them from \testing serveral weeks ago.

Patch done Rev 1438 \testing and merged 1439 \testing-egonhugeist
Available on trunk in two weeks.

Thank you for that hint. But the other thread is talking about my branch where these lines do not exsits...

Michael
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Locked