[project @ 2005-06-30 02:51:27 by unknown_lamer]
[clinton/bobotpp.git] / source / Socket.C
index aa85976..1e8b89b 100644 (file)
@@ -1,5 +1,5 @@
 // Socket.C  -*- C++ -*-
-// Copyright (C) 2002 Clinton Ebadi
+// Copyright (C) 2002,2005 Clinton Ebadi
 // Copyright (c) 1997, 1998 Etienne BERNARD
 
 // This program is free software; you can redistribute it and/or modify
@@ -14,7 +14,8 @@
 
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
 
 #include "Socket.H"
 #include "Bot.H"
@@ -292,14 +293,15 @@ Socket::readLine()
     } while (r != '\n');
   
   if (pos > 1 && buf[pos-2] == '\r')
-    buf[pos-2] = '\0';
+    {
+      buf[pos-2] = '\0';
+      return String (buf.substr (0, pos - 2));
+    }
   else
-    buf[pos-1] = '\0';
-  
-  // c_str () is used because the String constructor for std::string
-  // will copy the entire std::string into it when we only want it to
-  // copy up to the first null.
-  return String (buf.c_str ());
+    {
+      buf[pos-1] = '\0';
+      return String (buf.substr (0, pos - 1));
+    }
 }
 
 String