aboutsummaryrefslogtreecommitdiff
path: root/libio/wfiledoalloc.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
committerUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
commita334319f6530564d22e775935d9c91663623a1b4 (patch)
treeb5877475619e4c938e98757d518bb1e9cbead751 /libio/wfiledoalloc.c
parent0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (diff)
downloadglibc-a334319f6530564d22e775935d9c91663623a1b4.zip
glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.gz
glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.bz2
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
Diffstat (limited to 'libio/wfiledoalloc.c')
-rw-r--r--libio/wfiledoalloc.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/libio/wfiledoalloc.c b/libio/wfiledoalloc.c
index 67a0517..2f8140b 100644
--- a/libio/wfiledoalloc.c
+++ b/libio/wfiledoalloc.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993, 1997, 1999, 2000, 2002, 2006
- Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1997, 1999, 2000, 2002 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
@@ -86,20 +85,35 @@ _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 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);
+ 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
+ }
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;
}