This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] Tidy a couple of istream functions


Hi,

tested x86-linux, committing to mainline.

Paolo.

/////////////
2004-05-21  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/istream.tcc (ignore): Remove redundant line.
	(readsome): Tidy, closely following 27.6.1.3, p30.
diff -urN libstdc++-v3-orig/include/bits/istream.tcc libstdc++-v3/include/bits/istream.tcc
--- libstdc++-v3-orig/include/bits/istream.tcc	2004-05-21 15:09:28.000000000 +0200
+++ libstdc++-v3/include/bits/istream.tcc	2004-05-21 17:27:41.000000000 +0200
@@ -659,7 +659,6 @@
 	      __streambuf_type* __sb = this->rdbuf();
 	      int_type __c;
 
-	      __n = std::min(__n, numeric_limits<streamsize>::max());
 	      while (_M_gcount < __n
 		     && !traits_type::eq_int_type(__c = __sb->sbumpc(), __eof))
 		{
@@ -740,14 +739,10 @@
 	  try
 	    {
 	      // Cannot compare int_type with streamsize generically.
-	      streamsize __num = this->rdbuf()->in_avail();
-	      if (__num >= 0)
-		{
-		  __num = std::min(__num, __n);
-		  if (__num)
-		    _M_gcount = this->rdbuf()->sgetn(__s, __num);
-		}
-	      else
+	      const streamsize __num = this->rdbuf()->in_avail();
+	      if (__num > 0)
+		_M_gcount = this->rdbuf()->sgetn(__s, std::min(__num, __n));
+	      else if (__num == -1)
 		__err |= ios_base::eofbit;
 	    }
 	  catch(...)

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