mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
libio: use stdout in puts and putchar, etc [BZ #24051].
GLIBC explicitly allows one to assign a new FILE pointer to stdout and other standard streams. printf and wprintf were honouring assignment to stdout and using the new value, but puts, putchar, and wide char variants did not. The stdout part is fixed here. The stdin part will be fixed in a followup.
This commit is contained in:
@ -33,15 +33,15 @@ _IO_puts (const char *str)
|
||||
{
|
||||
int result = EOF;
|
||||
size_t len = strlen (str);
|
||||
_IO_acquire_lock (_IO_stdout);
|
||||
_IO_acquire_lock (stdout);
|
||||
|
||||
if ((_IO_vtable_offset (_IO_stdout) != 0
|
||||
|| _IO_fwide (_IO_stdout, -1) == -1)
|
||||
&& _IO_sputn (_IO_stdout, str, len) == len
|
||||
&& _IO_putc_unlocked ('\n', _IO_stdout) != EOF)
|
||||
if ((_IO_vtable_offset (stdout) != 0
|
||||
|| _IO_fwide (stdout, -1) == -1)
|
||||
&& _IO_sputn (stdout, str, len) == len
|
||||
&& _IO_putc_unlocked ('\n', stdout) != EOF)
|
||||
result = MIN (INT_MAX, len + 1);
|
||||
|
||||
_IO_release_lock (_IO_stdout);
|
||||
_IO_release_lock (stdout);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user