diff options
| author | 2013-05-20 20:15:50 +0100 | |
|---|---|---|
| committer | 2013-06-06 01:45:04 +0100 | |
| commit | e01df6385ef2ad1c0a78ccdd08af9af3ce688264 (patch) | |
| tree | a6bbf02d3ec75274fdf2a6e47c110c6b8506d9f7 /src/users.cpp | |
| parent | Convert User::FormatNoticeMasks() to use std::string. (diff) | |
| download | inspircd++-e01df6385ef2ad1c0a78ccdd08af9af3ce688264.tar.gz inspircd++-e01df6385ef2ad1c0a78ccdd08af9af3ce688264.tar.bz2 inspircd++-e01df6385ef2ad1c0a78ccdd08af9af3ce688264.zip | |
Convert User::SendText to use std::string.
Diffstat (limited to 'src/users.cpp')
| -rw-r--r-- | src/users.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
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) +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) + 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 |
