View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0032404 | FPC | Packages | public | 2017-09-11 23:02 | 2018-07-30 23:26 |
Reporter | CudaText man | Assigned To | Michael Van Canneyt | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Product Version | 3.0.2 | Product Build | |||
Target Version | 3.2.0 | Fixed in Version | 3.1.1 | ||
Summary | 0032404: RegExpr: need WideUpperCase/WideLowerCase | ||||
Description | In Unicode define mode, need WideUpperCase instead of AnsiUpperCase 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}; end; end; { of function TRegExpr.InvertCaseFunction also, make this code more readable. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 39534 | ||||
FPCOldBugId | |||||
FPCTarget | |||||
Attached Files |
|
|
If using WideUpperCase, fix also condition "code >= 128". |
|
Can you please provide a test program that demonstrates the issue ? |
|
Doc about regex change case http://wiki.freepascal.org/CudaText#Change_case_on_replaces - in Lazarus, open new tab - enter text pro про - test that "про" dont change case: - call Replace dialog - enter from ".+", to "\U$0" - case changed only for EN word, not RU word |
|
I actually need a compileable demo program that demonstrates the bug, so I can enter it in the testsuite |
|
tst-regex-upcase.zip (2,137 bytes) |
|
Lazarus demo. attach. it shows non Unicode replace: up-case + low-case. RU text not changed. |
|
Thank you. Reworked to: home:~/Documents/tst-regex-upcase> cat testre.pp program testure; {$mode objfpc} {$H+} {$CODEPAGE UTF8} uses Classes, SysUtils, regexpr; var r: TRegExpr; s, s2: string; begin r:= TRegExpr.create; r.Expression:= '.+'; s:= 'pro про'; s2:= r.Replace(s, '\U$0', true); Writeln(Format('Upcase of "%s" -> "%s"', [s, s2])); s:= 'PRO ПРО'; s2:= r.Replace(s, '\L$0', true); Writeln(Format('Lowcase of "%s" -> "%s"', [s, s2])); end. home:~/Documents/tst-regex-upcase> fpc testre.pp home:~/Documents/tst-regex-upcase> ./testre Upcase of "pro про" -> "PRO про" Lowcase of "PRO ПРО" -> "pro ПРО" |
|
fix it in TRegExpr.Substitute if p0 < p1 then begin while p0 < p1 do begin case Mode of smodeOneLower, smodeAllLower: begin Ch := p0^; Ch := WideLowerCase(Ch)[1]; ResultPtr^ := Ch; if Mode = smodeOneLower then Mode := smodeNormal; end; smodeOneUpper, smodeAllUpper: begin Ch := p0^; Ch := WideUpperCase(Ch)[1]; ResultPtr^ := Ch; if Mode = smodeOneUpper then Mode := smodeNormal; end; but only if Unicode define on. |
|
Another solution/workaround seems to be here: (use UpCase for condition code) https://forum.lazarus.freepascal.org/index.php/topic,39578.msg272230.html#msg272230 |
|
Or Uppercase, which has unicodestring overloads |
|
Fixed, when compiled with uregexp, output of program is now: Upcase of "pro про" -> "PRO ПРО" Lowcase of "PRO ПРО" -> "pro про" |
Date Modified | Username | Field | Change |
---|---|---|---|
2017-09-11 23:02 | CudaText man | New Issue | |
2017-09-11 23:04 | CudaText man | Note Added: 0102788 | |
2017-09-12 10:00 | Michael Van Canneyt | Note Added: 0102793 | |
2017-09-12 10:00 | Michael Van Canneyt | Assigned To | => Michael Van Canneyt |
2017-09-12 10:00 | Michael Van Canneyt | Status | new => feedback |
2017-09-12 11:54 | CudaText man | Note Added: 0102798 | |
2017-09-12 11:54 | CudaText man | Status | feedback => assigned |
2017-09-12 11:56 | Michael Van Canneyt | Note Added: 0102799 | |
2017-09-12 11:57 | Michael Van Canneyt | Status | assigned => feedback |
2017-09-12 12:08 | CudaText man | File Added: tst-regex-upcase.zip | |
2017-09-12 12:09 | CudaText man | Note Added: 0102800 | |
2017-09-12 12:09 | CudaText man | Status | feedback => assigned |
2017-09-12 12:15 | Michael Van Canneyt | Note Added: 0102801 | |
2017-09-12 13:50 | CudaText man | Note Added: 0102803 | |
2018-01-26 20:43 | rd0x | Note Added: 0106055 | |
2018-01-26 22:03 | Thaddy de Koning | Note Added: 0106057 | |
2018-07-30 23:26 | Michael Van Canneyt | Fixed in Revision | => 39534 |
2018-07-30 23:26 | Michael Van Canneyt | Note Added: 0109773 | |
2018-07-30 23:26 | Michael Van Canneyt | Status | assigned => resolved |
2018-07-30 23:26 | Michael Van Canneyt | Fixed in Version | => 3.1.1 |
2018-07-30 23:26 | Michael Van Canneyt | Resolution | open => fixed |
2018-07-30 23:26 | Michael Van Canneyt | Target Version | => 3.2.0 |