Also avoid unnecessarily setting errno when testing for TTY.
+2011-05-21 Ulrich Drepper <drepper@gmail.com>
+
+ [BZ #12792]
+ * libio/filedoalloc.c (local_isatty): New function.
+ (_IO_file_doallocate): Use local_isatty.
+ * stdio-common/perror.c (perror): In case a new stream is used
+ forward the stream error.
+ * stdio-common/vfprintf.c (ARGCHECK): For read-only streams also set
+ error flag.
+
2011-05-20 Ulrich Drepper <drepper@gmail.com>
[BZ #11869]
-GNU C Library NEWS -- history of user-visible changes. 2011-5-20
+GNU C Library NEWS -- history of user-visible changes. 2011-5-21
Copyright (C) 1992-2009, 2010, 2011 Free Software Foundation, Inc.
See the end for copying conditions.
12454, 12460, 12469, 12489, 12509, 12510, 12511, 12518, 12527, 12541,
12545, 12551, 12582, 12583, 12587, 12597, 12601, 12611, 12625, 12626,
12631, 12650, 12653, 12655, 12660, 12681, 12685, 12711, 12713, 12714,
- 12717, 12723, 12724, 12734, 12738, 12746, 12766, 12775
+ 12717, 12723, 12724, 12734, 12738, 12746, 12766, 12775, 12792
* The RPC implementation in libc is obsoleted. Old programs keep working
but new programs cannot be linked with the routines in libc anymore.
-/* Copyright (C) 1993, 1997, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1997, 2001, 2002, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
4. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
-
+
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# include <device-nrs.h>
#endif
+
+static int
+local_isatty (int fd)
+{
+ int save_errno = errno;
+ int res = isatty (fd);
+ __set_errno (save_errno);
+ return res;
+}
+
+
/*
* Allocate a file buffer, or switch to unbuffered I/O.
* Per the ANSI C standard, ALL tty devices default to line buffered.
#ifdef DEV_TTY_P
DEV_TTY_P (&st) ||
#endif
- isatty (fp->_fileno))
+ local_isatty (fp->_fileno))
fp->_flags |= _IO_LINE_BUF;
}
#if _IO_HAVE_ST_BLKSIZE
-/* Copyright (C) 1991-1993,1997,1998,2000-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993,1997,1998,2000-2005,2011
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
position. Since the stderr stream wasn't used so far we just
write to the descriptor. */
perror_internal (fp, s, errnum);
+
+ if (_IO_ferror_unlocked (fp))
+ stderr->_flags |= _IO_ERR_SEEN;
+
/* Close the stream. */
fclose (fp);
}
CHECK_FILE (S, -1); \
if (S->_flags & _IO_NO_WRITES) \
{ \
+ S->_flags |= _IO_ERR_SEEN; \
__set_errno (EBADF); \
return -1; \
} \