This is the mail archive of the gcc-bugs@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]

Bug in endl (libio)


In libio/iostream.cc, endl() should check if the stream can accept chars
before writing its eol.  I found this because I was forcibly setting a
stream to eof in order to create a null stream that swallows chars (long
story - NT has a less than stellar iostream).  In that situation, eols
still get written.

This is true in 2.95.2 as well as the latest cvs according to the web
pages.

Here's a patch:

--- /usr/project/gcc/iostream.cc.orig    Fri May 19 17:37:57 2000
+++ /usr/project/gcc/iostream.cc   Fri May 19 17:40:36 2000
@@ -963,7 +963,9 @@

 ostream& endl(ostream& outs)
 {
-    return flush(outs.put('\n'));
+    if (opfx)
+        flush(outs.put('\n'));
+    return outs;
 }

 istream& lock(istream& ins)


Jerry Quinn
jlquinn@us.ibm.com



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