Problem with line buffering and getc function on 1.7.33.
Corinna Vinschen
corinna-cygwin@cygwin.com
Sat Mar 12 19:39:00 GMT 2016
On Mar 11 16:05, Kaz Kylheku wrote:
> We can reproduce the problem with just file streams using
> a much simpler program:
>
> #include <stdio.h>
>
> int main(void)
> {
> FILE *out = fopen("file", "w+");
> setvbuf(out, (char *) NULL, _IOLBF, 0);
> getc(out);
> clearerr(out);
> fseek(out, 0, SEEK_SET);
> putc('a', out);
> putc('b', out);
> putc('c', out);
> putc('d', out);
> putc('e', out);
> putc('\n', out);
> fclose(out);
> return 0;
> }
>
> The contents of file end up being "\n": one empty
> line, instead of "abcde\n":
>
> $ cat file
>
> $
Thanks for the testcase. I can reproduce the issue and I see where the
problem occurs, but I'm still puzzled. Comparing the code in our newlib
C library with its BSD counterparts, I could swear the same behaviour
happens on OpenBSD as well. If not (which needs testing), I wonder why
and where newlib's actually different. Right now I don't see the
difference.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160312/649b1c9d/attachment.sig>
More information about the Cygwin
mailing list