On 2022-06-20 04:22, Takashi Yano wrote:
On Mon, 20 Jun 2022 17:59:35 +0900
Takashi Yano wrote:
Isn't this a bug of newlib? Try following code.
#include <stdio.h>
int main()
{
printf("%d\n", getchar());
printf("%d\n", feof(stdin));
printf("%d\n", getchar());
return 0;
}
If you press Ctrl-D at the first getchar(), the second getchar()
does not return EOF while it does in linux.
The following patch seems to resolve the issue.
diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c
index ccedc7af7..843163b7e 100644
--- a/newlib/libc/stdio/refill.c
+++ b/newlib/libc/stdio/refill.c
@@ -47,11 +47,9 @@ __srefill_r (struct _reent * ptr,
fp->_r = 0; /* largely a convenience for callers */
-#ifndef __CYGWIN__
/* SysV does not make this test; take it out for compatibility */
if (fp->_flags & __SEOF)
return EOF;
-#endif
/* if not already reading, have to be reading and writing */
if ((fp->_flags & __SRD) == 0)
However, I am not sure what this #ifndef __CYGWIN__ is for.
Ah, I confirmed that System V (Solaris 11.4) behaves like that.
Does cygwin aim for System V compatibility???
The emphasis has shifted over the years from Solaris etc. compatibility
when Sparc desktops were ubiquitous (and I switched from DJGPP to
Cygwin) to Linux etc. compatibility as PCs displaced RISC boxes.
I think ACLs were the last new feature where Solaris was considered vs
POSIX.
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple