View Issue Details

IDProjectCategoryView StatusLast Update
0038442FPCFCLpublic2021-03-24 18:06
ReporterMartin Friebe Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platform64bit IntelOSwin 10 
Product Version3.2.1 
Fixed in Version3.3.1 
Summary0038442: regexpression ignores changed to modifier
DescriptionThe following code matches the same pattern twice, but changes the ModifierI.
The match after the change is performed as if the modifier was not changed.

Works fine in 3.0.4
Steps To Reproduceprogram Project1;
{$mode objfpc}{$H+}
uses
  RegExpr;

var
  RegExprEngine : TRegExpr;
begin
  // first "NOT ignore case"
  RegExprEngine := TRegExpr.Create();

  RegExprEngine.ModifierI := False; // Do not ignore case
  RegExprEngine.Expression := '(t...),';
  RegExprEngine.InputString := 'Text and more Text, texting';
  writeln(RegExprEngine.ExecPos(1));
  WriteLn(RegExprEngine.MatchPos[0]);

  RegExprEngine.ModifierI := True;
  RegExprEngine.Expression := '(t...),';
  RegExprEngine.InputString := 'Text and more Text, texting';
  writeln(RegExprEngine.ExecPos(1));
  WriteLn(RegExprEngine.MatchPos[0]);



  // first "ignore case"
  RegExprEngine := TRegExpr.Create();

  RegExprEngine.ModifierI := True;
  RegExprEngine.Expression := '(t...),';
  RegExprEngine.InputString := 'Text and more Text, texting';
  writeln(RegExprEngine.ExecPos(1));
  WriteLn(RegExprEngine.MatchPos[0]);

  RegExprEngine.ModifierI := False; // Do not ignore case
  RegExprEngine.Expression := '(t...),';
  RegExprEngine.InputString := 'Text and more Text, texting';
  writeln(RegExprEngine.ExecPos(1));
  WriteLn(RegExprEngine.MatchPos[0]);

  ReadLn;
end.


----
Output

FALSE
-1
FALSE // should be true
-1
TRUE
15
TRUE // should be false
15
TagsNo tags attached.
Fixed in Revision49047
FPCOldBugId
FPCTarget4.0.0
Attached Files

Activities

Martin Friebe

2021-02-08 15:38

manager   ~0128822

It seems it is not fixed upstream either.

The version shipped with 3.0.4 calls
Procedure TRegExpr.ExecPrim
...
  if not IsProgrammOk //###0.929


function TRegExpr.IsProgrammOk : boolean;
...
  // check modifiers
  if fModifiers <> fProgModifiers //###0.941
   then InvalidateProgramm;


Newer versions contain the comment

Procedure TRegExpr.ExecPrim
  // Don't check IsProgrammOk here! it causes big slowdown in test_benchmark!

----------------------------
If IsProgrammOk is not called, then at least
  if fModifiers <> fProgModifiers //###0.941
   then InvalidateProgramm;
should be needed.

Martin Friebe

2021-02-08 15:39

manager   ~0128823

https://github.com/andgineer/TRegExpr/issues/238

CudaText man

2021-02-08 15:56

reporter   ~0128824

I posted the fix to https://github.com/Alexey-T/TRegExpr
please check.

ravi dion

2021-02-12 20:56

reporter   ~0128915

cool, fpc regex should be replaced

Martin Friebe

2021-03-24 15:16

manager   ~0129854

Link to the diff that fixes the issue upstream https://github.com/Alexey-T/TRegExpr/commit/b3617f0028248d132cd83716b28f57d8501a7e2f.diff

Michael Van Canneyt

2021-03-24 18:06

administrator   ~0129859

Fixed. I'll see if this can be merged to 3.2.2

Issue History

Date Modified Username Field Change
2021-02-05 20:23 Martin Friebe New Issue
2021-02-08 15:38 Martin Friebe Note Added: 0128822
2021-02-08 15:39 Martin Friebe Note Added: 0128823
2021-02-08 15:56 CudaText man Note Added: 0128824
2021-02-12 20:56 ravi dion Note Added: 0128915
2021-03-24 15:16 Martin Friebe Note Added: 0129854
2021-03-24 18:06 Michael Van Canneyt Assigned To => Michael Van Canneyt
2021-03-24 18:06 Michael Van Canneyt Status new => resolved
2021-03-24 18:06 Michael Van Canneyt Resolution open => fixed
2021-03-24 18:06 Michael Van Canneyt Fixed in Version => 3.3.1
2021-03-24 18:06 Michael Van Canneyt Fixed in Revision => 49047
2021-03-24 18:06 Michael Van Canneyt FPCTarget => 4.0.0
2021-03-24 18:06 Michael Van Canneyt Note Added: 0129859