From d4e3eb56e271a40043c86abce55b0391e03b0ca2 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 2 Dec 2005 16:02:47 +0000 Subject: [PATCH] Fixed splitter algorithm to not trim off spaces in a 'final' parameter git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2117 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree.cpp | 52 +++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 31621d980..710a57d97 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -896,34 +896,53 @@ class TreeSocket : public InspSocket std::deque Split(std::string line, bool stripcolon) { std::deque n; + if (!strchr(line.c_str(),' ')) + { + n.push_back(line); + return n; + } std::stringstream s(line); std::string param = ""; n.clear(); int item = 0; while (!s.eof()) { - s >> param; - //if ((param != "") && (param != "\n")) - //{ - if ((param.c_str()[0] == ':') && (item)) + char c; + s.get(c); + if (c == ' ') + { + log(DEBUG,"Push back %s",param.c_str()); + n.push_back(param); + param = ""; + item++; + } + else + { + if (!s.eof()) { - char* str = (char*)param.c_str(); - str++; - param = str; - std::string append; + param = param + c; + } + if ((param == ":") && (item > 0)) + { + param = ""; while (!s.eof()) { - append = ""; - s >> append; - if (append != "") + s.get(c); + if (!s.eof()) { - param = param + " " + append; + param = param + c; } } + log(DEBUG,"Push back %s",param.c_str()); + n.push_back(param); + param = ""; } - item++; - n.push_back(param); - //} + } + } + if (param != "") + { + log(DEBUG,"Push back %s",param.c_str()); + n.push_back(param); } return n; } @@ -938,6 +957,7 @@ class TreeSocket : public InspSocket return true; Srv->Log(DEBUG,"inbound-line: '"+line+"'"); std::deque params = this->Split(line,true); + log(DEBUG,"*** Number of params = %d",params.size()); std::string command = ""; std::string prefix = ""; if (((params[0].c_str())[0] == ':') && (params.size() > 1)) @@ -1111,7 +1131,7 @@ class TreeSocket : public InspSocket } return true; - break; + break; } return true; } -- 2.39.5