This is the mail archive of the
mailing list for the Cygwin project.
Re: Problem with line buffering and getc function on 1.7.33.
- From: Kaz Kylheku <920-082-4242 at kylheku dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 11 Mar 2016 16:05:02 -0800
- Subject: Re: Problem with line buffering and getc function on 1.7.33.
- Authentication-results: sourceware.org; auth=none
- References: <a0c23290b3a8502552dcf149fbfa5f90 at mail dot kylheku dot com> <56E34346 dot 9010000 at gmail dot com>
On 11.03.2016 14:14, Marco Atzeri wrote:
On 11/03/2016 22:57, Kaz Kylheku wrote:
On 11.03.2016 12:08, Yaakov Selkowitz wrote:
On 2016-03-11 13:16, Kaz Kylheku wrote:
On a Cygwin installation version 1.7.33-2(0.280/5/3), I encountered
an odd issue.
This is a 15-month old release which is no longer supported. Please
update to 2.4.1.
Do you mean, "Please update to 2.4.1, it is fixed there!"
or do you mean "You haven't done enough with that minimal
C repro case; please keep investigating against
the latest code?"
#2 please verify if the issue is still present in the last code.
We don't have the bandwith to check claims on older release.
on 2.4.1 the output is:
That confirms that the issue is still there.
We can reproduce the problem with just file streams using
a much simpler program:
FILE *out = fopen("file", "w+");
setvbuf(out, (char *) NULL, _IOLBF, 0);
fseek(out, 0, SEEK_SET);
The contents of file end up being "\n": one empty
line, instead of "abcde\n":
$ cat file
The necessary ingredients seem to be: open the stream for update;
put into line buffered mode; do some input. In this program,
replacing putc with fputs doesn't make the problem go away;
the workaround isn't working:
However, if we do it as one string, then the file does contain
the correct line:
This sequence also gets us correct file contents:
HOWEVER, these distracting effects are because GCC is
optimizing one-character fputs calls into _fputc calls.
Annoyingly, this happens even with gcc -O0.
The clearerr and fseek calls are red herrings; they seem to make
make no difference. I put in the fseek for formal ISO C compliance:
ISO C says that before performing an output operation on an update
stream whose last operation was input, we "shall" perform a
positioning operation. (No sanely implemented libc actually
breaks code that doesn't meet this silly requirement.)
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple