andgineer / TRegExpr

Regular expressions (regex), pascal.
https://regex.sorokin.engineer/en/latest/
MIT License
174 stars 63 forks source link

Fix compilation for Delphi Rio (10.3) #241

Closed mvancanneyt closed 3 years ago

mvancanneyt commented 3 years ago

The _uppercase and _lowercase functions no longer work in Delphi Rio (delphi 10.3).

{$IFDEF FPC} {$IFDEF UniCode} Result := UnicodeUpperCase(Ch)[1]; {$ELSE} Result := AnsiUpperCase(Ch)[1]; {$ENDIF} {$ELSE} {$IFDEF UniCode} {$IFDEF D_XE4} Result := Ch.ToUpper; {$ELSE}

The last line does not compile. I changed it to Result := UpperCase(Ch)[1] Which is of course horribly inefficient.

Similar in _lowercase {$IFDEF UniCode} {$IFDEF D_XE4} Result := LowerCase(Ch)[1]; {$ELSE}

There may be another (better) solution, but I am pressed for time so I didn't investigate further.

Alexey-T commented 3 years ago

it is bad in 10.3, how about last 10.4 Sydney? http://docwiki.embarcadero.com/Libraries/Sydney/en/System.Character this tells we must use TCharacter.

can you test on 10.4 and give the patch? I don't have Delphi today.

mvancanneyt commented 3 years ago

I don't have 10.4

mvancanneyt commented 3 years ago

System.Character is not in the uses list. So of course that will not work... Not even for D2009. When I add System.Character to the uses list and change to {$IFDEF D_XE4} Result := Ch.ToLower; {$ELSE} Then it works.

Alexey-T commented 3 years ago

I will try to get Delphi in next days. or give the pull-req, pls.

Alexey-T commented 3 years ago

@andgineer Pls close.