From 298f76d8b85157763dfdca5a0ec82d5bfa0272f2 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 28 Apr 2005 16:06:48 +0000 Subject: Added new and improved GetBuffer function based on research on crappy redhat 7.3 git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1241 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/connection.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/connection.cpp b/src/connection.cpp index c77db382c..8a6557e9d 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -166,18 +166,21 @@ void ircd_connector::ClearBuffer() std::string ircd_connector::GetBuffer() { - char* line = (char*)ircdbuffer.c_str(); - char ret[MAXBUF]; - std::stringstream* stream = new std::stringstream(std::stringstream::in | std::stringstream::out); - *stream << ircdbuffer; - stream->getline(ret,MAXBUF); - while ((*line != '\n') && (strlen(line))) - line++; - if ((*line == '\n') || (*line == '\r')) - line++; - ircdbuffer = line; - delete stream; - return ret; + // Fix by Brain 28th Apr 2005 + // seems my stringstream code isnt liked by linux + // EVEN THOUGH IT IS CORRECT! Fixed by using a different + // (SLOWER) algorithm... + char* line = (char*)ircdbuffer.c_str(); + std::string ret = ""; + while ((*line != '\n') && (strlen(line))) + { + ret = ret + *line; + line++; + } + if ((*line == '\n') || (*line == '\r')) + line++; + ircdbuffer = line; + return ret; } bool ircd_connector::MakeOutboundConnection(char* newhost, int newport) -- cgit v1.2.3