View Issue Details

IDProjectCategoryView StatusLast Update
0034429FPCPackagespublic2018-10-20 14:12
ReporterAndrey SorokinAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWindowsOSWindowsOS Version10
Product VersionProduct Build57972 
Target Version3.2.0Fixed in Version3.3.1 
Summary0034429: Different esc-sequences processing in regular expression and substitution string in RegExpr.Replace
DescriptionIn regular expression RegExpr treats '\n' as #$a, but in substitution string
(Replace function) by default '\n' treated platform-dependent.
So for windows this is #$d#$a.
Steps To ReproduceReplaceRegExpr('\n', 'abc'#$D#$A'def', '\n', True)
returns abc'#$D#$D#$A'def
Additional InformationI created pull-request in github but do not see how to send it to SVN
https://github.com/graemeg/freepascal/pull/15

I implemented in Replace function the same esc-sequences processing as in main regular expression parser.

And switched off {$DEF UseOsLineEndOnReplace}.

For old behaviour of '\n' in substitution strings you have to uncomment {$DEF UseOsLineEndOnReplace}

TagsNo tags attached.
Fixed in Revision39993
FPCOldBugId
FPCTarget
Attached Files

Activities

Maxim Ganetsky

2018-10-17 14:01

reporter   ~0111440

This issue belongs to FPC project. Moving.

cordylus

2018-10-18 00:24

reporter   ~0111445

The pull request as a patch: https://github.com/graemeg/freepascal/pull/15.patch

Alexey Tor.

2018-10-18 09:12

reporter   ~0111448

Andrey,
maybe you can fix this issue too?
Thanks for your work on RegExpr.
https://bugs.freepascal.org/view.php?id=34130

Andrey Sorokin

2018-10-18 15:42

reporter   ~0111453

I am not sure we have to fit it - wrote answer in the ticket.

Michael Van Canneyt

2018-10-20 14:11

administrator   ~0111482

I have done this differently.

The define is now a property of the RE object.

We should not expect people to recompile the unit if they want different behaviour, moreover people may want different behaviour depending on the situation:
for example in a text editor you may want to be able to set this depending on the line-ending setting of the current file in the editor.

I also converted the tests to unit tests.

Thanks for the patch !

Michael Van Canneyt

2018-10-20 14:12

administrator   ~0111483

Forgot to add, the default is to use OS line ending, for backwards compatibility.

Issue History

Date Modified Username Field Change
2018-10-17 10:51 Andrey Sorokin New Issue
2018-10-17 14:01 Maxim Ganetsky Note Added: 0111440
2018-10-17 14:01 Maxim Ganetsky Project Packages => FPC
2018-10-18 00:24 cordylus Note Added: 0111445
2018-10-18 09:12 Alexey Tor. Note Added: 0111448
2018-10-18 15:42 Andrey Sorokin Note Added: 0111453
2018-10-20 12:43 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-10-20 12:43 Michael Van Canneyt Status new => assigned
2018-10-20 14:11 Michael Van Canneyt Fixed in Revision => 39993
2018-10-20 14:11 Michael Van Canneyt Note Added: 0111482
2018-10-20 14:11 Michael Van Canneyt Status assigned => resolved
2018-10-20 14:11 Michael Van Canneyt Fixed in Version => 3.3.1
2018-10-20 14:11 Michael Van Canneyt Resolution open => fixed
2018-10-20 14:11 Michael Van Canneyt Target Version => 3.2.0
2018-10-20 14:12 Michael Van Canneyt Note Added: 0111483