[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: probable bug/shortcoming of gawk v3.0.3
From: |
tt |
Subject: |
Re: probable bug/shortcoming of gawk v3.0.3 |
Date: |
09 Mar 2001 13:39:30 +0200 |
"David Inman" <address@hidden> writes:
> On Win98SE with Cygwin's GAWK V3.0.3 (latest I could find compiled):
> 1. Create a file with one character, say 'a' and NO '\n' following it.
> You may find this tricky to do since many programs just slap a '\n'
> on the end when you don't want one.
> 2. Create a file as above with the letter 'a' but include the '\n' at the end
> of the line.
> 3. Read the files with getline. (The files were not specified on the command
> line
> invoking gawk.)
>
> I have not found a way to differentiate between these two files when reading
> the files within GAWK by comparing what is read. I need to know if a '\n'
> was part of the last line of the file or not and the getline functions seems
> to
> treat them as if they were identical. I played with RS, ORS, FS, ... to no
> avail.
Could be a Windows problem, but under Linux with gawk 3.04:
bash$ echo a>a2
bash$ dd if=a2 of=a1 bs=1 count=1
1+0 records in
1+0 records out
bash$ ls -l a?
-rw-rw-r-- 1 tt tt 1 Mar 9 13:32 a1
-rw-rw-r-- 1 tt tt 2 Mar 9 13:32 a2
bash$ awk 'BEGIN{RS="\0"; getline < "a1"; print length()}'
1
bash$ awk 'BEGIN{RS="\0"; getline < "a2"; print length()}'
2
Using null as RS is not POSIXly correct but seems to work with gawk.
You could also use a long string, say "NoSuChStRiNg" or whatever
(won't work with standard awk any better though).
--
Tapani Tarvainen