Make fread fill the internal file buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changelog:
	dlls/msvcrt/file.c: fread()
	Use MSVCRT_fgetc when buffer is not filled to refill

The patch applies on top of the fget(w)s patch. It saves a lot of server
calls for small values of size*nmemb.
-- 
Uwe Bonnes                bon@elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
--- wine/dlls/msvcrt/file.c_fget	2003-10-05 13:31:11.000000000 +0200
+++ wine/dlls/msvcrt/file.c	2003-10-05 13:35:52.000000000 +0200
@@ -1977,15 +1977,19 @@
 	} else
 		return 0;
   }
-  if(rcnt) pread = _read(file->_file,ptr, rcnt);
-  if (MSVCRT_flags[file->_file] & MSVCRT__IOEOF)
-     /* expose feof condition in the flags
-        MFC tests file->_flag for feof, and doesn't not call feof())
-    */
+  while (rcnt && ! (file->_flag & MSVCRT__IOEOF))
+    {
+      pread = MSVCRT_fgetc(file);
+      if (pread != MSVCRT_EOF)
+	{
+	  *(char*)ptr = pread;
+	  ptr = (char*)ptr + 1;
+	  rcnt --;
+	  read++;
+	}
+      else
     file->_flag |= MSVCRT__IOEOF;
-  if (pread <= 0)
-    pread = 0;
-  read+=pread;
+    }
   return read / size;
 }
 


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux