View Issue Details

IDProjectCategoryView StatusLast Update
0031379FPCPackagespublic2020-01-19 06:35
ReporterDo-wan Kim Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilitysometimes
Status closedResolutionfixed 
Platformx86OSWindows 
Product Version3.1.1 
Fixed in Version3.3.1 
Summary0031379: RegExpr with Ignorecase make unexpected result with UTF-8 pattern string.
DescriptionI got unexpected result utf-8 pattern string with ignorecase modifier.

I found that problem with this function.
AnsiUpperCase returns #0 with 0000128~0000255 character and it make unexpected result.
My codepage is CP-949.

class function TRegExpr.InvertCaseFunction (const Ch : REChar) : REChar;
 begin
  {$IFDEF UniCode}
  if Ch >= 0000128
   then Result := Ch
  else
  {$ENDIF}
   begin
    Result := {$IFDEF FPC}AnsiUpperCase (Ch) [1]{$ELSE} {$IFDEF SYN_WIN32}REChar (CharUpper (PChar (Ch))){$ELSE}REChar (toupper (integer (Ch))){$ENDIF} {$ENDIF};
    if Result = Ch
     then Result := {$IFDEF FPC}AnsiLowerCase (Ch) [1]{$ELSE} {$IFDEF SYN_WIN32}REChar (CharLower (PChar (Ch))){$ELSE}REChar(tolower (integer (Ch))){$ENDIF} {$ENDIF};
    {$IFNDEF UniCode} // fix problem
    if Result=#0 then
      Result:=Ch;
    {$ENDIF}
   end;
 end; { of function TRegExpr.InvertCaseFunction

TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

Do-wan Kim

2017-02-11 15:11

reporter  

regexpr.pas.patch (795 bytes)   
Index: packages/regexpr/src/regexpr.pas
===================================================================
--- packages/regexpr/src/regexpr.pas	(revision 35418)
+++ packages/regexpr/src/regexpr.pas	(working copy)
@@ -1240,6 +1240,10 @@
     Result := {$IFDEF FPC}AnsiUpperCase (Ch) [1]{$ELSE} {$IFDEF SYN_WIN32}REChar (CharUpper (PChar (Ch))){$ELSE}REChar (toupper (integer (Ch))){$ENDIF} {$ENDIF};
     if Result = Ch
      then Result := {$IFDEF FPC}AnsiLowerCase (Ch) [1]{$ELSE} {$IFDEF SYN_WIN32}REChar (CharLower (PChar (Ch))){$ELSE}REChar(tolower (integer (Ch))){$ENDIF} {$ENDIF};
+    {$IFNDEF UniCode}
+    if Result=#0 then
+      Result:=Ch;
+    {$ENDIF}
    end;
  end; { of function TRegExpr.InvertCaseFunction
 --------------------------------------------------------------}
regexpr.pas.patch (795 bytes)   

CudaText man

2019-12-25 20:56

reporter   ~0120063

I need feedback on my RegExpr patches. Test your issue and if not ok, report to Github.
https://github.com/andgineer/TRegExpr
it will be posted to FPC later.

Michael Van Canneyt

2020-01-18 16:44

administrator   ~0120518

Presumably fixed by Alexey's patch.

Do-wan Kim

2020-01-19 06:35

reporter   ~0120530

Thank you :)

Issue History

Date Modified Username Field Change
2017-02-11 15:11 Do-wan Kim New Issue
2017-02-11 15:11 Do-wan Kim File Added: regexpr.pas.patch
2019-12-25 20:56 CudaText man Note Added: 0120063
2020-01-18 16:44 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-01-18 16:44 Michael Van Canneyt Status new => resolved
2020-01-18 16:44 Michael Van Canneyt Resolution open => fixed
2020-01-18 16:44 Michael Van Canneyt Fixed in Version => 3.3.1
2020-01-18 16:44 Michael Van Canneyt FPCTarget => 3.2.0
2020-01-18 16:44 Michael Van Canneyt Note Added: 0120518
2020-01-19 06:35 Do-wan Kim Status resolved => closed
2020-01-19 06:35 Do-wan Kim Note Added: 0120530