Thread View: gnu.g++.lib.bug
2 messages
2 total messages
Started by Johan Garpendahl
Tue, 05 Jan 1993 18:16
strstream bug?
Author: Johan Garpendahl
Date: Tue, 05 Jan 1993 18:16
Date: Tue, 05 Jan 1993 18:16
46 lines
1780 bytes
1780 bytes
I'm not quite sure that this is a bug, it's rather a difference in how
cfront handles strstreams and how (lib)g++ handles strstreams.
Here is an example:
////////////////////////////
#include <string.h>
#include <strstream.h>
#include <iostream.h>
char* str1="Now is the time for all good men ... 13:34:20 beep";
main()
{
istrstream istr1(str1, strlen(str1) + 1);
char buf[256];
while(istr1 >> buf) cout << buf << " "; // Don't forget to say "beep"
cout << endl;
istrstream istr2(str1, strlen(str1) + 1);
while(istr2.good()) { // Try again!
istr2 >> buf; // That's better!
cout << buf << " ";
}
cout << endl;
}
////////////////////////////
Compile with cfront and it prints the whole string twice.
Compile with (lib)g++ and it loses the "beep" the first time.
I can find good arguments for both behaviours.
Is it the program that is badly written?
Is there a definition of how it should work?
BTW, I last tried it with g++-2.3.3 and libg++-2.3.
Regards,
Johan
___________________________________________________________________________
Johan Garpendahl | Email: garp@isy.liu.se
Linkoping University | Phone: +46 - 13 - 28 13 24
Dept. of Electrical Engineering | Fax : +46 - 13 - 13 92 82
S-581 83 LINKOPING // SWEDEN | May the Source be with you.
Re: strstream bug?
Author: bothner
Date: Tue, 05 Jan 1993 16:37
Date: Tue, 05 Jan 1993 16:37
25 lines
1033 bytes
1033 bytes
Please try the following:
===================================================================
RCS file: /rel/cvsfiles/devo/libg++/iostream/iostream.C,v
retrieving revision 1.32
diff -c -r1.32 iostream.C
*** 1.32 1992/10/17 00:26:36
--- iostream.C 1993/01/06 08:35:46
***************
*** 161,167 ****
for (;;) {
ch = sb->sbumpc();
if (ch == EOF) {
! set(ios::eofbit|ios::failbit);
break;
}
else if (isspace(ch)) {
--- 161,167 ----
for (;;) {
ch = sb->sbumpc();
if (ch == EOF) {
! set(ios::eofbit);
break;
}
else if (isspace(ch)) {
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads