[PATCH v2] libio: Add test case for fflush

Frederic Berat fberat@redhat.com
Thu Nov 7 11:06:50 GMT 2024


On Thu, Nov 7, 2024 at 11:40 AM Florian Weimer <fweimer@redhat.com> wrote:

> * Frederic Berat:
>
> >> That's the only value 2 in the test, and it's using fgetc, not fgets?
> >
> > Correct, the difference with my original test resides in the content
> > size of the file, here I tried with the source code, which has a size
> > of 1424 bytes, while in my original test, the text file had a size of
> > 3 bytes.  My original assumption was that there was a difference by 1,
> > but actually with fgets, the position seems to be set to file
> > (buffer?) content size - 1.
>
> After the fflush or before the fflush?  Again, without the actual test
> you are looking at, it's difficult to help you.
>
>
$> echo -n "0:1" > test.txt
$> ./fflush_fgets test.txt
Without unget:
fgets: Position in stream before fflush: 3
fgets: Position in stream after fflush: 1
With unget:
fgets: Position in stream before fflush: 3
fgets: Position in stream after fflush: 2
Without unget:
fgetc: Position in stream before fflush: 3
fgetc: Position in stream after fflush: 2
With unget:
fgetc: Position in stream before fflush: 3
fgetc: Position in stream after fflush: 1


> Thanks,
> Florian
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20241107/1b48fe85/attachment.htm>


More information about the Libc-alpha mailing list