ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 37660] New: - using replace with <replacetoken>&#10;</replacetoken>
Date Mon, 28 Nov 2005 07:40:25 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37660>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37660

           Summary: using replace with <replacetoken>&#10;</replacetoken>
           Product: Ant
           Version: 1.6.5
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: louguang@vip.sina.com


Hello:
    Recently in my work, I needed to change all the ‘\n’ to ‘\nSomeWords’. I 
wrote the build file as following:
<project name="xxx-test" basedir="." default="test1">
  
  <target name="test1">
    
    <copy file="originalForReplaced.txt" tofile="forReplaced.txt" 
overwrite="true">
    </copy>
    <replace file="forReplaced.txt" value="&#10;SomeWords" >
      <replacetoken>&#10;</replacetoken>
    </replace>
  </target>

</project>

originalForReplaced.txt

hello
world

note:between the hello and world is '\n' not '\r\n'

	But failed. I looked into the source code, discovered that the string 
to be replaced and to be replaced with have all been processed so that ‘\n’ are 
replaced with ‘\r\n’. but the string contains the whole text is not processed. 
So if the lines of the text are terminated with ‘\n’, all the line breaks will 
not be replaced. Then I added the code of:

	newString = stringReplace(newString, "\r\n","\n", false);
        newString = stringReplace(newString, "\n", StringUtils.LINE_SEP, false);

in org.apache.tools.ant.taskdefs.Replace.processFile
the problem is resolved.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message