summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/users.h2
-rw-r--r--src/users.cpp29
2 files changed, 12 insertions, 19 deletions
diff --git a/include/users.h b/include/users.h
index 9f732f134..941e57667 100644
--- a/include/users.h
+++ b/include/users.h
@@ -601,7 +601,7 @@ class CoreExport User : public Extensible
* @param LinePrefix text to prefix each complete line with
* @param TextStream the text to send to the user
*/
- void SendText(const std::string &LinePrefix, std::stringstream &TextStream);
+ void SendText(const std::string& linePrefix, std::stringstream& textStream);
/** Write to the user, routing the line if the user is remote.
*/
diff --git a/src/users.cpp b/src/users.cpp
index e0d420311..468c2aa36 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1159,28 +1159,21 @@ void User::SendText(const char *text, ...)
SendText(line);
}
-void User::SendText(const std::string &LinePrefix, std::stringstream &TextStream)
-{
- char line[MAXBUF];
- int start_pos = LinePrefix.length();
- int pos = start_pos;
- memcpy(line, LinePrefix.data(), pos);
- std::string Word;
- while (TextStream >> Word)
+void User::SendText(const std::string& linePrefix, std::stringstream& textStream)
+{
+ std::string line;
+ std::string word;
+ while (textStream >> word)
{
- int len = Word.length();
- if (pos + len + 12 > MAXBUF)
+ size_t lineLength = linePrefix.length() + line.length() + word.length() + 3; // "\s\n\r"
+ if (lineLength > ServerInstance->Config->Limits.MaxLine)
{
- line[pos] = '\0';
- SendText(std::string(line));
- pos = start_pos;
+ SendText(linePrefix + line);
+ line.clear();
}
- line[pos] = ' ';
- memcpy(line + pos + 1, Word.data(), len);
- pos += len + 1;
+ line += " " + word;
}
- line[pos] = '\0';
- SendText(std::string(line));
+ SendText(linePrefix + line);
}
/* return 0 or 1 depending if users u and u2 share one or more common channels