summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/anope.h14
-rw-r--r--src/socket_transport.cpp4
2 files changed, 9 insertions, 9 deletions
diff --git a/include/anope.h b/include/anope.h
index 354c0bda5..28bc50512 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -159,24 +159,24 @@ namespace Anope
* Trim leading and trailing white spaces from the string.
*/
- inline string& ltrim()
+ inline string& ltrim(const Anope::string &what = " \t\r\n")
{
- while (!this->_string.empty() && isspace(this->_string[0]))
+ while (!this->_string.empty() && what.find(this->_string[0]) != Anope::string::npos)
this->_string.erase(this->_string.begin());
return *this;
}
- inline string& rtrim()
+ inline string& rtrim(const Anope::string &what = " \t\r\n")
{
- while (!this->_string.empty() && isspace(this->_string[this->_string.length() - 1]))
+ while (!this->_string.empty() && what.find(this->_string[this->_string.length() - 1]) != Anope::string::npos)
this->_string.erase(this->_string.length() - 1);
return *this;
}
- inline string& trim()
+ inline string& trim(const Anope::string &what = " \t\r\n")
{
- this->ltrim();
- this->rtrim();
+ this->ltrim(what);
+ this->rtrim(what);
return *this;
}
diff --git a/src/socket_transport.cpp b/src/socket_transport.cpp
index 26653e55f..6293ea385 100644
--- a/src/socket_transport.cpp
+++ b/src/socket_transport.cpp
@@ -63,8 +63,8 @@ const Anope::string BufferedSocket::GetLine()
return "";
Anope::string str = this->read_buffer.substr(0, s + 1);
this->read_buffer.erase(0, s + 1);
- this->read_buffer.ltrim();
- return str.trim();
+ this->read_buffer.ltrim("\r\n");
+ return str.trim("\r\n");
}
void BufferedSocket::Write(const char *buffer, size_t l)