ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Pantages <ppant...@xtera.com>
Subject Replace.java and "\n"
Date Tue, 08 Jan 2002 03:16:09 GMT
Hi all,

I am using ant 1.4.1 on Solaris 2.7, j2dsdk 1.3.1

I was having trouble replacing a token with a value containing newline
"\n". The replace task was just printing out the two characters
'\' & 'n' instead of newline.

E.g., 
   <replace
     file="filename"
     token="#BlaBla"
     value="\n#BlaBla"
   />

Was insertng \n#BlaBla into my file.

I looked into the source for replace task and at the Replace.processFile()
method. I see where the \n is supposed to be handled at line 325 or so:
...
String val = stringReplace(value.getText(), "\n", linesep);
String tok = stringReplace(token.getText(), "\n", linesep);
...

The prob. is, the "\n" in the replace call is converted to 0x0a, and
of course never matches the characters '\','n' in my token or val.

If I switch the replaced string to "\\n", the replace task does what I
expect, i.e., switches the "\n" to the unix newline 0x0a.

...
String val = stringReplace(value.getText(), "\\n", linesep);
String tok = stringReplace(token.getText(), "\\n", linesep);
...

So.... is this is really a bug or am I missing something obvious...? I
see that the file is dated 1999 and find it doubtful that this could
go unnoticed for so long.


Thanks, PdP

-- 
----------------------------------------------------------------------------
|Paul Pantages                       | Xtera Communications Inc.            |
|  pdp@xtera.com                     | 500 W. Bethany                       |
|                                    | Allen, Texas 75013                   |
|                                    | 972 649 5208 (voice)                 |
| Avenge September 11...             | 214 726 5332 (cell)                  |
----------------------------------------------------------------------------


*****
This email may contain confidential, privileged and protected information
from disclosure. Any review or distribution by others is strictly
prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.
*****



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


Mime
View raw message