summary refs log tree commit diff
path: root/libio/iofgets.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-10-03 20:44:20 +0000
committerJakub Jelinek <jakub@redhat.com>2005-10-03 20:44:20 +0000
commita5a11654ea5ea89bfffb295fbb2f17cbb45839b6 (patch)
tree2078fd7b828ae3b4c030e6722c53bdc81542a511 /libio/iofgets.c
parent6543cff055c298ea3ec718b356f6c2115e8797ae (diff)
downloadglibc-a5a11654ea5ea89bfffb295fbb2f17cbb45839b6.tar.gz
glibc-a5a11654ea5ea89bfffb295fbb2f17cbb45839b6.tar.xz
glibc-a5a11654ea5ea89bfffb295fbb2f17cbb45839b6.zip
Updated to fedora-glibc-20051003T2040
Diffstat (limited to 'libio/iofgets.c')
-rw-r--r--libio/iofgets.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libio/iofgets.c b/libio/iofgets.c
index 879cc975a3..601b1746a1 100644
--- a/libio/iofgets.c
+++ b/libio/iofgets.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 1999, 2002, 2003
+/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2005
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -41,6 +41,14 @@ _IO_fgets (buf, n, fp)
   CHECK_FILE (fp, NULL);
   if (n <= 0)
     return NULL;
+  if (__builtin_expect (n == 1, 0))
+    {
+      /* Another irregular case: since we have to store a NUL byte and
+	 there is only room for exactly one byte, we don't have to
+	 read anything.  */
+      buf[0] = '\0';
+      return buf;
+    }
   _IO_acquire_lock (fp);
   /* This is very tricky since a file descriptor may be in the
      non-blocking mode. The error flag doesn't mean much in this