This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with line buffering and getc function on 1.7.33.

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


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]