This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

A libio patch


This is a fix for a bug triggered by VSX-PCT. It also optimizes the
code a little bit. Please check it out.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---
Wed Oct 28 19:29:29 1998  H.J. Lu  <hjl@gnu.org>

	* libio/iogetline.c ((_IO_getline_info): Don't read again if
	there is nothing to read.

Index: libio/iogetline.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc/libio/iogetline.c,v
retrieving revision 1.1.1.4
diff -u -p -r1.1.1.4 iogetline.c
--- iogetline.c	1998/08/26 15:57:53	1.1.1.4
+++ iogetline.c	1998/10/29 03:36:17
@@ -57,6 +57,7 @@ _IO_getline_info (fp, buf, n, delim, ext
      int *eof;
 {
   char *ptr = buf;
+  int again = 1;
   if (eof != NULL)
     *eof = 0;
   while (n != 0)
@@ -64,12 +65,22 @@ _IO_getline_info (fp, buf, n, delim, ext
       _IO_ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c;
+
+	  if (!again)
+	    break;
+
+	  c = __uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof) *eof = c;
 	      break;
 	    }
+
+	  /* If we got less than we asked for, we should not try again.
+	     It will only cause a read error. */
+	  again = (fp->_IO_read_end - fp->_IO_read_ptr) >= n;
+
 	  if (c == delim)
 	    {
  	      if (extract_delim > 0)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]