A few small bug fixes.
authorarjen <arjen>
Sat, 28 Sep 2002 06:42:11 +0000 (06:42 +0000)
committerarjen <arjen>
Sat, 28 Sep 2002 06:42:11 +0000 (06:42 +0000)
src/string.cpp

index 6221f2f..6a23007 100644 (file)
@@ -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.
 **
 
 /*****************************
    $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 <stdio.h>
 #include <ctype.h>
@@ -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;
 }