newlines issue in gawk

Miroslav Šulc <[email protected]>
Newsgroups gmane.comp.windows.gnu.user
Message-ID <[email protected]>
Hello,
I am experimenting currently with gawk-3.1.3-2 trying to grasp the basic 
principles and I have encountered the following issue. I have a simple 
text file data.txt containing this data: "aaa\r\n\r\nbbb\r\n\r\nccc", 
i.e. there is no "\r" or "\n" or "\r\n" at the end of the file.

I wonder, what the following gawk-script should output:

BEGIN{
    RS="\n\n+";
    ORS="";OFS="";
}

{
    print "\"",$0,"\"\n";
}

I assume, that it should be:

"aaa"
"bbb"
"ccc"

shouldn't it? Nevertheless, what I get is:

"aaa"
"bbb"
"cc"

i.e. the last "c" is mysteriously trimmed. Letting RS="" solves this 
issue, nevertheless I would like to understand, why the RS="\n\n+" 
version doesn't work. By the way, BINMODE is set to 0, so I presume, 
that the "\r\n" sequence is converted internally to "\n". Any suggestions?

Thanks in advance,
Mira

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.