diff options
author | Peter Powell <petpow@saberuk.com> | 2013-05-20 20:15:50 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2013-06-06 01:45:04 +0100 |
commit | e01df6385ef2ad1c0a78ccdd08af9af3ce688264 (patch) | |
tree | a6bbf02d3ec75274fdf2a6e47c110c6b8506d9f7 /src | |
parent | ef3799a43a24f4b3da5e785765a6e4c01353845c (diff) |
Convert User::SendText to use std::string.
Diffstat (limited to 'src')
-rw-r--r-- | src/users.cpp | 29 |
1 files changed, 11 insertions, 18 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) -{ - 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 |