aboutsummaryrefslogtreecommitdiff
path: root/libio/wfiledoalloc.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-12-13 23:17:54 +0000
committerUlrich Drepper <drepper@redhat.com>2006-12-13 23:17:54 +0000
commit1e88bd0f1b62bd58f283241877a0b3e66e199e76 (patch)
tree5c7c36e5188e78363b6fb79df0b6b7a843511dbd /libio/wfiledoalloc.c
parentf72386ad7c5009995612b4117a34de8c96d1509c (diff)
downloadglibc-1e88bd0f1b62bd58f283241877a0b3e66e199e76.tar
glibc-1e88bd0f1b62bd58f283241877a0b3e66e199e76.tar.gz
glibc-1e88bd0f1b62bd58f283241877a0b3e66e199e76.tar.bz2
glibc-1e88bd0f1b62bd58f283241877a0b3e66e199e76.zip
[BZ #2337]
2006-12-13 Ulrich Drepper <drepper@redhat.com> [BZ #2337] * libio/Makefile (tests): Add tst-setvbuf1. * libio/tst-setvbuf1.c: New file. 2006-12-08 Jakub Jelinek <jakub@redhat.com> [BZ #2337] * libio/genops.c (__uflow): Fix a typo. * libio/wfiledoalloc.c (_IO_wfile_doallocate): Don't stat nor set _IO_LINE_BUF bit here. Size the wide buffer based on the narrow buffer size. 2006-11-24 Jakub Jelinek <jakub@redhat.com> [BZ #2337] * libio/libio.h (_IO_FLAGS2_USER_WBUF): Define. * libio/wgenops.c (_IO_wsetb, _IO_wdefault_finish): Test and set _IO_FLAGS2_USER_WBUF bit in _flags2 instead of _IO_USER_BUF bit in _flags. * libio/wstrops.c (_IO_wstr_overflow, enlarge_userbuf, _IO_wstr_finish): Likewise. * libio/wmemstream.c (open_wmemstream): Likewise. * libio/fileops.c (_IO_new_file_close_it): Call _IO_set[bgp] even for wide streams.
Diffstat (limited to 'libio/wfiledoalloc.c')
-rw-r--r--libio/wfiledoalloc.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/libio/wfiledoalloc.c b/libio/wfiledoalloc.c
index 2f8140b0ac..67a05175b2 100644
--- a/libio/wfiledoalloc.c
+++ b/libio/wfiledoalloc.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1993, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1997, 1999, 2000, 2002, 2006
+ 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
@@ -85,35 +86,20 @@ _IO_wfile_doallocate (fp)
_IO_FILE *fp;
{
_IO_size_t size;
- int couldbetty;
wchar_t *p;
- struct _G_stat64 st;
/* Allocate room for the external buffer. */
if (fp->_IO_buf_base == NULL)
INTUSE(_IO_file_doallocate) (fp);
- if (fp->_fileno < 0 || _IO_SYSSTAT (fp, &st) < 0)
- {
- couldbetty = 0;
- size = _IO_BUFSIZ;
-#if 0
- /* do not try to optimise fseek() */
- fp->_flags |= __SNPT;
-#endif
- }
- else
- {
- couldbetty = S_ISCHR (st.st_mode);
-#if _IO_HAVE_ST_BLKSIZE
- size = st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize;
-#else
- size = _IO_BUFSIZ;
-#endif
- }
+ /* If narrow buffer is user allocated (set by setvbuf etc.),
+ use that size as the size of the wide buffer, when it is
+ allocated by _IO_file_doallocate, multiply that by size
+ of the wide character. */
+ size = fp->_IO_buf_end - fp->_IO_buf_base;
+ if ((fp->_flags & _IO_USER_BUF))
+ size = (size + sizeof (wchar_t) - 1) / sizeof (wchar_t);
ALLOC_WBUF (p, size * sizeof (wchar_t), EOF);
INTUSE(_IO_wsetb) (fp, p, p + size, 1);
- if (couldbetty && isatty (fp->_fileno))
- fp->_flags |= _IO_LINE_BUF;
return 1;
}