Re: fseek/fgetc puzzle

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

 



On Mon, Feb 20, 2023 at 10:21:31PM +1100, Darren Tucker wrote:

> > My suggestion of course fails to explain why there's only one 'B'.
> > I would create the initial file separately from the test program.
> 
> The "od" call in the middle of the above example proves there's only
> one byte after the first fclose.

Ah, so it does.  What happens
if you do everything except the last call at the end?
printf("fputc B = %d\n", fputc('B', f));

What happens if you don't read the last byte?  I realize
you will need to for the original problem?

What I'm wondering is if somehow reading the byte puts it in
the output buffer.

What happens if you create an initial two byte file, say "AB", and try
to write a 'C'?  If you read the B, I guess we expect 'ABBC' at this
point.  If you read the 'A', do you get 'ABAC' or something else?

I wish I had a box I could reproduce the problem on (see below).

> You get the AAB on Linux and MacOS?  Which versions?  I get AB on both
> OSX High Sierra and Fedora 36.  Maybe it's sensitive to locale
> settings?

I mis-quoted.  I get the expected two byte 'AB' output on both.
Sorry for what must have been a surprising confusion.

-- 
nw
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



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

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux