[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] Help with glibc memory streams



Andreas Fuchs wrote:
> 
> Would you now please accept that there absolutely _has_ to be an
> end-of-line character at the end of the last line in a file so that
> fgets does not return NULL when reading the last line?
> 

I would, but what you say does _not_ explain the discrepancy that
I observe to be a bug. [Also, as you'll see what you say is
wrong on its own]

orion:libc$ ./filestream 
Read: testorion:libc$ 
orion:libc$ ./memstream  
read error!

The file "filestream" uses is exactly 4 bytes long, and consists
of the characters "test"
orion:libc$ hexdump testfile
0000000 6574 7473                              
0000004
So, there doesn't have to be an end-of-line character at the end
of the last line in a file to make fgets work all right!!

This might be a bug that depends on platform/version of the development
software. Which version are you using? I'm using latest glibc in woody,
and the architecture is i386

I could write a workaround if the code I worked on was to be exclusive
for memstreams but that isn't the case. For some reason, it would
be better if the same code would work for the mem stream as well
as the file stream.

Could you please verify this discrepancy? You need to compile and run
both files.

Thanks for your attention!

-- 
Eray (exa) Ozkural
Comp. Sci. Dept., Bilkent University, Ankara
e-mail: erayo@cs.bilkent.edu.tr
www: http://www.cs.bilkent.edu.tr/~erayo



Reply to: