Recent

Author Topic: FPC Git main: bug, which I cannot repro in a small demo  (Read 180 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2715
    • UVviewsoft
FPC Git main: bug, which I cannot repro in a small demo
« on: May 08, 2026, 01:16:59 am »
Lazarus Git main from today,
FPC Git main from yesterday.

Bug appears in cudatext editor: statusbar cells have the LEFT align, instead of CENTER align.
Debugging on linux-x64-gtk2 shows that in this procedure

Code: Pascal  [Select][+][-]
  1. procedure TfmMain.UpdateStatusbarPanelsFromString(const AText: string);
  2. var
  3.   SPanel, SItem: string;
  4.   NIndex, NSize, NTag: integer;
  5.   Al: TAlignment;
  6.   SepAll, SepItem: TATStringSeparator;
  7.   bAutoSize, bStretch, bHotTrack: boolean;
  8. begin
  9. ...
  10.  
  11.   SepAll.Init(AText, '|');
  12.   repeat
  13.     if not SepAll.GetItemStr(SPanel) then Break;
  14.  
  15.     SepItem.Init(SPanel);
  16.     NTag:= 0;
  17.     NIndex:= StatusbarMain.PanelCount;
  18.     bStretch:= false;
  19.     bHotTrack:= false;
  20.  
  21.     SepItem.GetItemStr(SItem);
  22.     case SItem of
  23.       'caret':   begin NTag:= StatusbarTag_Caret; bHotTrack:= true; end;
  24.       'enc':     begin NTag:= StatusbarTag_Enc; bHotTrack:= true; end;
  25.       'ends':    begin NTag:= StatusbarTag_LineEnds; bHotTrack:= true; end;
  26.       'lexer':   begin NTag:= StatusbarTag_Lexer; bHotTrack:= true; end;
  27.       'tabsize': begin NTag:= StatusbarTag_TabSize; bHotTrack:= true; end;
  28.       'ins':     begin NTag:= StatusbarTag_InsOvr; bHotTrack:= true; end;
  29.       'msg':     begin NTag:= StatusbarTag_Msg; bStretch:= true; end;
  30.       'selmode': begin NTag:= StatusbarTag_SelMode; bHotTrack:= true; end;
  31.       'wrap':    begin NTag:= StatusbarTag_WrapMode; bHotTrack:= true; end;
  32.       'zoom':    begin NTag:= StatusbarTag_Zoom; bHotTrack:= false; end;
  33.       'ro':      begin NTag:= StatusbarTag_ReadOnly; bHotTrack:= false; end;
  34.       else Continue;
  35.     end;
  36.  
  37.     SepItem.GetItemStr(SItem);
  38.     bAutoSize:= SItem='A';
  39.     if bAutoSize then
  40.       Al:= taLeftJustify
  41.     else
  42.       Al:= AppStringToAlignment(SItem);
  43.  
  44. ...
  45.   until false;
  46. end;
  47.  

code goes into place shown with '// <--'

Code: Pascal  [Select][+][-]
  1.    
  2.     SepItem.GetItemStr(SItem);
  3.     bAutoSize:= SItem='A';
  4.     if bAutoSize then
  5.       Al:= taLeftJustify // <--
  6.  

even  when SItem='C' (C means CENTER) !
I extracted this fragment to a small demo, and repeated LPI file <CompilerOptions> part from cudatext.lpi ( https://github.com/Alexey-T/CudaText/blob/master/app/cudatext.lpi ). It did not help. In cudatext.lpi I have default build-mode - problem don't appear, and 'linux-x64-gtk2' mode - probem appears. I copied <CompilerOptions> from the needed build-mode.

Small demo which cannot repeat the bug, is like this:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3.   STest, SItem: string;
  4.   bAutoSize: boolean;
  5.   Al: TAlignment;
  6. begin
  7.   STest:= '0,C';
  8.   SItem:= STest[3];
  9.   bAutoSize:= SItem='A';
  10.   if bAutoSize then
  11.     Al:= taLeftJustify
  12.   else
  13.     Al:= taCenter;
  14.  
  15.   if Al=taLeftJustify then
  16.     caption:= 'wrong'
  17.   else
  18.     caption:= 'ok';
  19.  
  20. end;  
« Last Edit: May 08, 2026, 07:32:04 pm by AlexTP »

AlexTP

  • Hero Member
  • *****
  • Posts: 2715
    • UVviewsoft
Re: FPC Git main: bug, which I cannot repro in a small demo
« Reply #1 on: May 08, 2026, 07:32:53 pm »
If I change Optimization Level from O2 to O1 in the cudatext project-options, bug disappears (statusbar cells have the centering now).

 

TinyPortal © 2005-2018