View Issue Details

IDProjectCategoryView StatusLast Update
0025156FPCCompilerpublic2013-10-12 13:39
ReporterDenis Golovan Assigned ToMartin Friebe  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Summary0025156: trunk incorrectly inlines on linux/unix
DescriptionMFriebe: Moved orig description to "additional info". Last Note from reporter:
----------------------

I've attached the project1.lpr showing the issue.
Basically it shows the problem is nor in widestring manager, nor codepage, but it's a compiler bug.

It sends the same argument twice to WideCompareText instead of actual parameters. That results in as if WideCompareText returns 0 for every combination of its arguments.

I suspect it has something to do with making WideCompareText inline, as adding non-inline version like following solves the issue.

function WideCompareText(const s1, s2 : WideString) : PtrInt;
begin
  result:=widestringmanager.CompareTextWideStringProc(s1,s2);
end;
Additional InformationHi

Trying to attach TSynCompletion component to TSynEdit with case-sensivity off does not work. I've attached a patch to fix the issue. It works only for UTF8 enconding, but I guess Lazarus uses it anyway.

====skipped============
FAutoComplete:=TSynCompletion.Create(nil);
FAutoComplete.OnExecute:=@OnAutoCompleteExecute;
FAutoComplete.CaseSensitive:=False; //!!!
====skipped============

Tested against Lazarus rev. 43021
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Relationships

duplicate of 0024915 closedFlorian Crash in Lazarus after r24953 

Activities

Denis Golovan

2013-10-06 19:46

reporter  

synedit_completion_caseinsens.patch (647 bytes)   
diff --git a/components/synedit/syncompletion.pas b/components/synedit/syncompletion.pas
index 67505b2..9c5eadf 100644
--- a/components/synedit/syncompletion.pas
+++ b/components/synedit/syncompletion.pas
@@ -1089,8 +1089,8 @@ begin
         end;
     end else begin
       for i := 0 to Pred(ItemList.Count) do
-        if 0 = WideCompareText(UTF8Decode(fCurrentString),
-                       UTF8Decode(Copy(ItemList[i], 1, Length(fCurrentString))))
+        if 0 = UTF8CompareText( fCurrentString,
+                                Copy(ItemList[i], 1, Length(fCurrentString)) )
         then begin
           Position := i;
           break;

Martin Friebe

2013-10-07 20:55

manager   ~0070633

Utf8 is ok. All text in SynEdit is handled in utf8 currently.

But I can not reproduce.

New App, add TSynEdit to form, and:

procedure TForm1.FormCreate(Sender: TObject);
begin
FAutoComplete:=TSynCompletion.Create(nil);
//FAutoComplete.CaseSensitive:=true ;
FAutoComplete.CaseSensitive:=False; //!!!
FAutoComplete.AddEditor(SynEdit1);

FAutoComplete.ItemList.Add('abc');
FAutoComplete.ItemList.Add('abar');
FAutoComplete.ItemList.Add('afoo');
FAutoComplete.ItemList.Add('AAA');
end;

If I enter "a" and press ctrl-space, then "abc" is selected.
If I enter "A" and press ctrl-space, then again "abc" is selected.

If I change to
  FAutoComplete.CaseSensitive:=true ;
and then:

If I enter "a" and press ctrl-space, then "abc" is selected.
If I enter "A" and press ctrl-space, then "AAA" is selected.

---
Please provide a full example, that fails with the current implementation.

Which version of FPC are you using? I tested 2.6.2

Denis Golovan

2013-10-09 19:28

reporter  

sens.tar.gz (3,089 bytes)

Denis Golovan

2013-10-09 19:33

reporter  

sens-off.gif (8,343 bytes)   
sens-off.gif (8,343 bytes)   

Denis Golovan

2013-10-09 19:33

reporter  

sens-on.gif (5,969 bytes)   
sens-on.gif (5,969 bytes)   

Denis Golovan

2013-10-09 19:35

reporter   ~0070701

I've attached a project archive and two screenshots with the results.
Basically case-ibsensitivity does not work.

I use FPC rev. 25535 (2.7.1 branch)

Martin Friebe

2013-10-09 20:43

manager   ~0070703

Works here with 25452 trunk.

But from your description it sounds to me that the widestring manager in FPC is broken for your platform (XP, I believe? / I use Vista)

If "WideCompareText" works fine for case insensitive compare in 2.6.2, and not in 2.7.1 this is an fpc problem.

So this should be reported to fpc.

If this is the case, then you should be able to produce a simplified example from the existing code.

---

Having said that, using Utf8Compare may be a refactoring I might use anyway.

But applying a fix to an issue, without knowing what causes it, means potentially just hiding it for the one specific case. That is just not a good idea. So it must be clear at first why it fails.

It is also possible, that "fCurrentString" has an encoding (strings in fpc 2.7.1 have encoding) that influences the comparison.
Though TStrings.items and fCurrentString are both "String". But it may depend how your RTL is build.
If that is the case, then that may mean major changes needed.

There should be a way to read a strings encoding. But I am not sure how.

Martin Friebe

2013-10-09 20:53

manager   ~0070704

Last edited: 2013-10-09 20:53

View 2 revisions

I started a thread on the fpc mail list. You may want to join it, and follow this up.
http://lists.freepascal.org/lists/fpc-devel/2013-October/032880.html

Denis Golovan

2013-10-09 22:12

reporter   ~0070709

> FPC is broken for your platform (XP, I believe? / I use Vista)
No, that happens under Linux UTF8 locale as well.

>It is also possible, that "fCurrentString" has an encoding (strings in fpc 2.7.1 have encoding) that influences the comparison.
Hm, only latins were used as you see.

Thanks for the thread, I'll comment something as soon as somebody wants to reply :)

Martin Friebe

2013-10-09 23:50

manager   ~0070713

Just tested with today's trunk. Still works here.

So there are 2 possibilities:
1) It is fpc, in which case it needs to be fixed there. Unfortunately I can not contribute to solving it, as it works on my PC

2) Since the function should work: Something in the way it is called (e.g. encoding) is wrong. Then that would have to be fixed in SynEdit.

In case 2: Simple replacing the function by another just because it appears to work today makes no sense, because the original issue would still exist, and could still cause problems (e.g with other data / or if Utf8Compare changed).

This means, without either your help, or the help of anyone who can reproduce this, there is no way I can fix anything right now.

Denis Golovan

2013-10-11 19:08

reporter  

project1.lpr (950 bytes)

Denis Golovan

2013-10-11 19:14

reporter   ~0070748

Last edited: 2013-10-11 19:15

View 2 revisions

I've attached the project1.lpr showing the issue.
Basically it shows the problem is nor in widestring manager, nor codepage, but it's a compiler bug.

It sends the same argument twice to WideCompareText instead of actual parameters. That results in as if WideCompareText returns 0 for every combination of its arguments.

I suspect it has something to do with making WideCompareText inline, as adding non-inline version like following solves the issue.

function WideCompareText(const s1, s2 : WideString) : PtrInt;
begin
  result:=widestringmanager.CompareTextWideStringProc(s1,s2);
end;

Martin Friebe

2013-10-11 19:39

manager   ~0070751

Thanks for the investigation / Moved to FPC project.

Denis Golovan

2013-10-11 20:03

reporter   ~0070753

I've checked the latest trunk version (rev.25737) and it looks like something fixed that.
At least my attached example no longer reproduces the problem.

Hm. How about a refactoring? :)

Florian

2013-10-11 20:05

administrator   ~0070754

I suspect this has been already fixed by r25684. Please retest with trunk HEAD.

Denis Golovan

2013-10-11 20:41

reporter   ~0070755

Ok.
I've checked using rev. 25748 and it works.
Other things started to crash, but that's another story :)

Martin Friebe

2013-10-11 21:36

manager   ~0070757

@Denis:

1) if it works now, then this can be closed?

2) The code in SynEdit may need some work, but that is not part of the bug tracker.

Denis Golovan

2013-10-11 21:50

reporter   ~0070758

1) yes
2) ok

Martin Friebe

2013-10-12 12:30

manager   ~0070762

Fixed in the meantime

for (2) I am on forum and mail list

Denis Golovan

2013-10-12 12:51

reporter   ~0070763

Thanks.

Issue History

Date Modified Username Field Change
2013-10-06 19:46 Denis Golovan New Issue
2013-10-06 19:46 Denis Golovan File Added: synedit_completion_caseinsens.patch
2013-10-06 21:28 Martin Friebe Assigned To => Martin Friebe
2013-10-06 21:28 Martin Friebe Status new => assigned
2013-10-07 20:55 Martin Friebe LazTarget => -
2013-10-07 20:55 Martin Friebe Note Added: 0070633
2013-10-07 20:55 Martin Friebe Status assigned => feedback
2013-10-09 19:28 Denis Golovan File Added: sens.tar.gz
2013-10-09 19:33 Denis Golovan File Added: sens-off.gif
2013-10-09 19:33 Denis Golovan File Added: sens-on.gif
2013-10-09 19:35 Denis Golovan Note Added: 0070701
2013-10-09 19:35 Denis Golovan Status feedback => assigned
2013-10-09 20:43 Martin Friebe Note Added: 0070703
2013-10-09 20:53 Martin Friebe Note Added: 0070704
2013-10-09 20:53 Martin Friebe Note Edited: 0070704 View Revisions
2013-10-09 22:12 Denis Golovan Note Added: 0070709
2013-10-09 23:50 Martin Friebe Note Added: 0070713
2013-10-11 19:08 Denis Golovan File Added: project1.lpr
2013-10-11 19:14 Denis Golovan Note Added: 0070748
2013-10-11 19:15 Denis Golovan Note Edited: 0070748 View Revisions
2013-10-11 19:36 Martin Friebe Assigned To Martin Friebe =>
2013-10-11 19:36 Martin Friebe Status assigned => new
2013-10-11 19:36 Martin Friebe Category Patch => -
2013-10-11 19:36 Martin Friebe Summary [SynEdit] Case-insensitive completion does not work => trunk incorrectly inlines on linux/unix
2013-10-11 19:36 Martin Friebe Description Updated View Revisions
2013-10-11 19:36 Martin Friebe Additional Information Updated View Revisions
2013-10-11 19:36 Martin Friebe Project Patches => FPC
2013-10-11 19:39 Martin Friebe Note Added: 0070751
2013-10-11 20:03 Denis Golovan Note Added: 0070753
2013-10-11 20:05 Florian Note Added: 0070754
2013-10-11 20:05 Florian Status new => feedback
2013-10-11 20:41 Denis Golovan Note Added: 0070755
2013-10-11 20:41 Denis Golovan Status feedback => new
2013-10-11 21:36 Martin Friebe Note Added: 0070757
2013-10-11 21:50 Denis Golovan Note Added: 0070758
2013-10-12 12:30 Martin Friebe Note Added: 0070762
2013-10-12 12:30 Martin Friebe Status new => resolved
2013-10-12 12:30 Martin Friebe Resolution open => fixed
2013-10-12 12:30 Martin Friebe Assigned To => Martin Friebe
2013-10-12 12:51 Denis Golovan Note Added: 0070763
2013-10-12 12:51 Denis Golovan Status resolved => closed
2013-10-12 13:38 Jonas Maebe Relationship added duplicate of 0024915
2013-10-12 13:39 Jonas Maebe Category - => Compiler