Bug 22661

Summary: Replace does not preserve line endings in multi line tokens
Product: Ant Reporter: Antoine Levy-Lambert <antoine>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: REOPENED ---    
Severity: normal CC: louguang, notifications
Priority: P3    
Version: 1.7.0   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Antoine Levy-Lambert 2003-08-22 15:45:03 UTC
The replace task does not preserve line endings properly.
In revision 1.46, I did a change to avoid \r\n to be changed into \r\r\n on 
Windows (problem reported via email by Morten Mortensen).
Now I have the problem that \n gets replaced into the system's line separator, 
in both source and replacement tokens.
This showed with the test9 of ReplaceTest failing on Windows when the files of 
the test cases were downloaded with the cygwin cvs client (so having \n instead 
or \r\n)
I am not sure what is the best way to tackle this issue.
Maybe not doing any replacements of line endings in (value, token) pairs ?
Not sure.
Comment 1 Antoine Levy-Lambert 2005-10-18 20:33:24 UTC
did not work on this bug, so I am putting it back to the community ...
Comment 2 Stefan Bodewig 2008-12-05 02:21:11 UTC
*** Bug 37660 has been marked as a duplicate of this bug. ***
Comment 3 Stefan Bodewig 2009-02-23 05:18:16 UTC

*** This bug has been marked as a duplicate of bug 46759 ***
Comment 4 Jesse Glick 2009-02-23 09:43:55 UTC
This must have been made duplicate by mistake?
Comment 5 Stefan Bodewig 2009-02-23 19:15:25 UTC
Yes, sorry, must have clicked on the wrong link.
Comment 6 dantewang 2018-03-29 02:43:59 UTC
There should be an option to switch between whether to take line ending into consideration in multi line token or not.

A typical use case is that the build.xml and the file that needs to be modified by <replace> task are both created in Linux (so both having \n), while the build is performed in Windows, where <replace> task replaces \n with \r\n in the token, causing the matching failure.