DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5515>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5515

Replace Task -- carriage returns

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |



------- Additional Comments From [EMAIL PROTECTED]  2001-12-22 07:08 -------
The real reason why I had my problem in the first place is that I was using 
more than one editor on my xml files. JBuilder will edit my file as an XML 
file, normalizing my line separators. Other editors edit my file as a text 
file, resulting in platform specific line separators...

Anyway, aside from my somewhat warped use case, there is another scenario where 
this code won't work as expected: someone writes their text file on one 
platform (i.e. Win2K), and then moves it to another platform where ant does its 
magic (i.e. Linux!).

To really get this to work in all cases, you'd have to do something like this:


                // line separators in values and tokens are "\n"
                // in order to compare with the file contents, replace them
                // as needed
                String linesep = System.getProperty("line.separator");
                String val = stringReplace(value.getText(), "\n", linesep);
                String tok = stringReplace(token.getText(), "\n", linesep);
                String newStr = stringReplace(newString, "\n", linesep);

                // for each found token, replace with value
                log("Replacing in " + src.getPath() + ": " + token.getText() 
+ " --> " + value.getText(), Project.MSG_VERBOSE);
                newString = stringReplace(newStr, tok, val);

Anyway, sorry about the schizophrenic bug report, but this has been a fun one 
to track down.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to