From 1d3d46661c1f2c44040b1a28bdef2dade3868a96 Mon Sep 17 00:00:00 2001 From: arjen Date: Sat, 28 Sep 2002 06:42:11 +0000 Subject: [PATCH] A few small bug fixes. --- src/string.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/string.cpp b/src/string.cpp index 6221f2f..6a23007 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -5,7 +5,7 @@ *********************** ** FILE NAME : string.cpp ** SYSTEM NAME : Andromeda X-Windows Encapsulation -** VERSION NUMBER : $Revision: 1.1 $ +** VERSION NUMBER : $Revision: 1.2 $ ** ** DESCRIPTION : String class implementation. ** @@ -23,12 +23,15 @@ /***************************** $Log: string.cpp,v $ - Revision 1.1 2002-07-25 08:01:27 arjen + Revision 1.2 2002-09-28 06:42:11 arjen + A few small bug fixes. + + Revision 1.1 2002/07/25 08:01:27 arjen First checkin, AXE release 0.2 *****************************/ -static const char RCSID[] = "$Id: string.cpp,v 1.1 2002-07-25 08:01:27 arjen Exp $"; +static const char RCSID[] = "$Id: string.cpp,v 1.2 2002-09-28 06:42:11 arjen Exp $"; #include #include @@ -351,14 +354,14 @@ String& substring::operator=(const String &x) /* Input and output */ -ostream& operator<<(ostream& s, const String& x) +std::ostream& operator<<(std::ostream& s, const String& x) { if (x.p->s) s << x.p->s; return s; } -istream& operator>>(istream& s, String& x) +std::istream& operator>>(std::istream& s, String& x) { char buf[1024]; int i; @@ -369,8 +372,11 @@ istream& operator>>(istream& s, String& x) i++; s.get(buf[i]); } - while (buf[i] != '\n'); - buf[i] = '\0'; + while (s && buf[i] != '\n'); + if (buf[i] == '\n') + { + buf[i] = '\0'; + } x = buf; return s; } -- 2.11.0