summaryrefslogtreecommitdiff
path: root/libio/filedoalloc.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-07-18 21:22:57 +0000
committerUlrich Drepper <drepper@redhat.com>2001-07-18 21:22:57 +0000
commit91099cf415727b7ff4a920913fabde84dcf7f8fa (patch)
tree6387472ec99c3be6dc58e5bf155cf226fc856564 /libio/filedoalloc.c
parentf2ebcef262efd8b706c13b4729edb19c0c503420 (diff)
downloadglibc-91099cf415727b7ff4a920913fabde84dcf7f8fa.tar.gz
Update.
2001-07-18 Ulrich Drepper <drepper@redhat.com> * libio/filedoalloc.c (_IO_file_doallocate): A few more minor cleanups and improvements. 2001-07-18 Andreas Schwab <schwab@suse.de> * posix/regex.c (WORDCHAR_P) [WCHAR]: Also return true for the underscore character. 2001-07-18 Jakub Jelinek <jakub@redhat.com> * malloc/malloc (new_heap): Don't call munmap for zero length. 2001-07-18 Ulrich Drepper <drepper@redhat.com> * libio/filedoalloc.c (_IO_file_doallocate): Use DEV_TTY_P if available to determine whether descriptor is for tty before calling isatty. * sysdeps/unix/sysv/linux/device-nrs.h: Define DEV_TTY_P. * sysdeps/generic/device-nrs.h: Likewise.
Diffstat (limited to 'libio/filedoalloc.c')
-rw-r--r--libio/filedoalloc.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c
index 1cabae83b5..c2e849a736 100644
--- a/libio/filedoalloc.c
+++ b/libio/filedoalloc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1997, 2001 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
@@ -58,6 +58,8 @@
#ifdef _LIBC
# undef isatty
# define isatty(Fd) __isatty (Fd)
+
+# include <device-nrs.h>
#endif
/*
@@ -73,7 +75,6 @@ _IO_file_doallocate (fp)
_IO_FILE *fp;
{
_IO_size_t size;
- int couldbetty;
char *p;
struct _G_stat64 st;
@@ -82,31 +83,29 @@ _IO_file_doallocate (fp)
function it points to. This is to make sure _IO_cleanup gets called
on exit. We call it from _IO_file_doallocate, since that is likely
to get called by any program that does buffered I/O. */
- if (_IO_cleanup_registration_needed)
+ if (__builtin_expect (_IO_cleanup_registration_needed != NULL, 0))
(*_IO_cleanup_registration_needed) ();
#endif
- if (fp->_fileno < 0 || _IO_SYSSTAT (fp, &st) < 0)
+ size = _IO_BUFSIZ;
+ if (fp->_fileno >= 0 && __builtin_expect (_IO_SYSSTAT (fp, &st), 0) >= 0)
{
- couldbetty = 0;
- size = _IO_BUFSIZ;
-#if 0
- /* do not try to optimise fseek() */
- fp->_flags |= __SNPT;
+ if (S_ISCHR (st.st_mode))
+ {
+ /* Possibly a tty. */
+ if (
+#ifdef DEV_TTY_P
+ DEV_TTY_P (st.st_rdev) ||
#endif
- }
- else
- {
- couldbetty = S_ISCHR (st.st_mode);
+ isatty (fp->_fileno))
+ fp->_flags |= _IO_LINE_BUF;
+ }
#if _IO_HAVE_ST_BLKSIZE
- size = st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize;
-#else
- size = _IO_BUFSIZ;
+ if (st.st_blksize > 0)
+ size = st.st_blksize;
#endif
}
ALLOC_BUF (p, size, EOF);
_IO_setb (fp, p, p + size, 1);
- if (couldbetty && isatty (fp->_fileno))
- fp->_flags |= _IO_LINE_BUF;
return 1;
}