mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 20:40:05 +00:00
Set stream errors in more cases
Also avoid unnecessarily setting errno when testing for TTY.
This commit is contained in:
parent
34a9094f49
commit
aec84f5395
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
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]
|
||||
|
4
NEWS
4
NEWS
@ -1,4 +1,4 @@
|
||||
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.
|
||||
|
||||
@ -16,7 +16,7 @@ Version 2.14
|
||||
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.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* 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
|
||||
@ -41,7 +41,7 @@
|
||||
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
|
||||
@ -74,6 +74,17 @@
|
||||
# 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.
|
||||
@ -109,7 +120,7 @@ _IO_file_doallocate (fp)
|
||||
#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
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* 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
|
||||
@ -73,6 +74,10 @@ perror (const char *s)
|
||||
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);
|
||||
}
|
||||
|
@ -52,6 +52,7 @@
|
||||
CHECK_FILE (S, -1); \
|
||||
if (S->_flags & _IO_NO_WRITES) \
|
||||
{ \
|
||||
S->_flags |= _IO_ERR_SEEN; \
|
||||
__set_errno (EBADF); \
|
||||
return -1; \
|
||||
} \
|
||||
|
Loading…
Reference in New Issue
Block a user