ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morten Mortensen <morten.morten...@tietoenator.com>
Subject RE: Carriage-returns in files ends up as "0D 0D 0A"
Date Sun, 27 Jul 2003 23:40:38 GMT

...Hmmmmmm...... The files, which I *tried* to attach, can be found on -

ftp://yelstream.org/pub/temp/ant-test/

- take e.g. the zip-file (less than 700 bytes) -

ftp://yelstream.org/pub/temp/ant-test/Ant-Test-0D0D0A.zip
(*passive* FTP works!)

The "usage-scenario" is there, too -
ftp://yelstream.org/pub/temp/ant-test/session.txt

    !

Regards,
  Morten Sabroe Mortensen


-----Original Message-----
From: Morten Mortensen
To: 'Antoine Levy-Lambert '; 'Ant Users List '
Sent: 28-07-03 01:30
Subject: RE: Carriage-returns in files ends up as "0D 0D 0A"


 
Hi Antoine and All,

Small zip-file attached! It contains "build.xml", "a.txt", "b.txt" and a
resulting "result.txt".

Unzip'ing the file and using it looks like this:

     -----
C:\ant-test>type build.xml
<project
  name="xxx"
  default="Doh"
>

  <target name="Doh">
    <copy file="a.txt" tofile="result.txt"/>
    <loadfile srcFile="b.txt" property="content"/>
    <replace file="result.txt" token="@@@Replace this@@@"
value="${content}"/>
  </target>

</project>

C:\ant-test>type a.txt
This is line one
This is line two
This is line three
@@@Replace this@@@

C:\ant-test>spider dump a.txt
 000000  54 68 69 73 20 69 73 20 6C 69 6E 65 20 6F 6E 65  This is line
one
 000010  0D 0A 54 68 69 73 20 69 73 20 6C 69 6E 65 20 74  ..This is line
t
 000020  77 6F 0D 0A 54 68 69 73 20 69 73 20 6C 69 6E 65  wo..This is
line
 000030  20 74 68 72 65 65 0D 0A 40 40 40 52 65 70 6C 61
three..@@@Repla
 000040  63 65 20 74 68 69 73 40 40 40 0D 0A              ce this@@@..

C:\ant-test>type b.txt
This is line four
This is line five
This is line six
C:\ant-test>spider dump b.txt
 000000  54 68 69 73 20 69 73 20 6C 69 6E 65 20 66 6F 75  This is line
fou
 000010  72 0D 0A 54 68 69 73 20 69 73 20 6C 69 6E 65 20  r..This is
line
 000020  66 69 76 65 0D 0A 54 68 69 73 20 69 73 20 6C 69  five..This is
li
 000030  6E 65 20 73 69 78                                ne six

C:\ant-test>ant
Buildfile: build.xml

Doh:

BUILD SUCCESSFUL
Total time: 1 second
C:\ant-test>type result.txt
This is line one
This is line two
This is line three
This is line four
This is line five
This is line six

C:\ant-test>spider dump result.txt
 000000  54 68 69 73 20 69 73 20 6C 69 6E 65 20 6F 6E 65  This is line
one
 000010  0D 0A 54 68 69 73 20 69 73 20 6C 69 6E 65 20 74  ..This is line
t
 000020  77 6F 0D 0A 54 68 69 73 20 69 73 20 6C 69 6E 65  wo..This is
line
 000030  20 74 68 72 65 65 0D 0A 54 68 69 73 20 69 73 20   three..This
is
 000040  6C 69 6E 65 20 66 6F 75 72 0D 0D 0A 54 68 69 73  line
four...This
 000050  20 69 73 20 6C 69 6E 65 20 66 69 76 65 0D 0D 0A   is line
five...
 000060  54 68 69 73 20 69 73 20 6C 69 6E 65 20 73 69 78  This is line
six
 000070  0D 0A                                            ..

C:\ant-test>ver

Microsoft Windows XP [Version 5.1.2600]

C:\ant-test>ant -version
Apache Ant version 1.5.3 compiled on April 16 2003
C:\ant-test>java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

C:\ant-test>
     -----

In "result.txt" - between "line four" and "line five", the offending
"0D,
0D, 0A" occurs - and again between "line five" and "line six".

(the results are the same on Win2000 and WinXP, JDK 1.4.1 and 1.4.2, ant
different Ant versions "1.5.3" compiled on April 9 and April 16,
respectively)

A guess is, that the "_0A_" in "0D _0A_" somehow is replaced with
"_0D_0A_"
and results in "0D _0D_0A_".

My emacs thinks this "result.txt"-kind of file is... weird - you know -
"^M"-marks it. 

So, let us hear a verdict, please.

Anybody got a way to work around this... thing?

Regards,
  Morten Sabroe Mortensen


-----Original Message-----
From: Antoine Levy-Lambert
To: Ant Users List
Sent: 27-07-03 22:49
Subject: Re: Carriage-returns in files ends up as "0D 0D 0A"

  Morten Sabroe Mortensen  wrote :
> Subject: Carriage-returns in files ends up as "0D 0D 0A"
>I want to read a multi-line text-file into a property with task
"loadfile",
>then replace this set of line into another multi-line-text-file at a
certain
>spot in the file using the task "replace". That is, I want to replace a
>string within one file with the content of another file.

>Within the final file, all carriage-returns between the lines from the
first
>file ends up as the sequence "0D, 0D, 0A" (have I seen by doing a
binary
>dump with a tool). So the problem is with the carriage-returns from the
file
>read by "loadfile".

Can you reply with a sample build file leading to the wrong behaviour.
Also
explain on which platform you are running your build on  (Windows ?).
You
can also open a bug report under http://nagoya.apache.org/bugzilla

Cheers

Antoine



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



 <<ATT73123.txt>> 

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


Mime
View raw message