diff options
| author | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-07-28 08:16:33 -0400 |
|---|---|---|
| committer | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-07-28 08:16:33 -0400 |
| commit | 971df4825c0d36a6931854c23732e829576e2654 (patch) | |
| tree | 28d687833c59a861014e81b41e8fa61acf16cb58 /include | |
| parent | aa9610a56ff18edd0703a3f391c90e1f8a761476 (diff) | |
Clean up send.cpp a bit to use Anope::string, as well as fix Anope::string's replace_all_* functions to actually work if the original and replacement strings are not the same length.
Diffstat (limited to 'include')
| -rw-r--r-- | include/anope.h | 12 | ||||
| -rw-r--r-- | include/extern.h | 6 |
2 files changed, 9 insertions, 9 deletions
diff --git a/include/anope.h b/include/anope.h index 7c3dcc65b..003927378 100644 --- a/include/anope.h +++ b/include/anope.h @@ -206,22 +206,22 @@ namespace Anope inline string replace_all_cs(const string &_orig, const string &_repl) { Anope::string new_string = *this; - size_type pos = new_string.find(_orig), orig_length = _orig.length(); + size_type pos = new_string.find(_orig), orig_length = _orig.length(), repl_length = _repl.length(); while (pos != npos) { - new_string.replace(pos, pos + orig_length, _repl); - pos = new_string.find(_orig, pos + orig_length); + new_string = new_string.substr(0, pos) + _repl + new_string.substr(pos + orig_length); + pos = new_string.find(_orig, pos + repl_length); } return new_string; } inline string replace_all_ci(const string &_orig, const string &_repl) { Anope::string new_string = *this; - size_type pos = new_string.find_ci(_orig), orig_length = _orig.length(); + size_type pos = new_string.find_ci(_orig), orig_length = _orig.length(), repl_length = _repl.length(); while (pos != npos) { - new_string.replace(pos, pos + orig_length, _repl); - pos = new_string.find_ci(_orig, pos + orig_length); + new_string = new_string.substr(0, pos) + _repl + new_string.substr(pos + orig_length); + pos = new_string.find_ci(_orig, pos + repl_length); } return new_string; } diff --git a/include/extern.h b/include/extern.h index 308a33de6..7d625ec91 100644 --- a/include/extern.h +++ b/include/extern.h @@ -175,7 +175,7 @@ E int strftime_lang(char *buf, int size, User *u, int format, struct tm *tm); E void syntax_error(const Anope::string &service, User *u, const Anope::string &command, int msgnum); E const char *getstring(NickAlias *na, int index); E const char *getstring(const NickCore *nc, int index); -E const char *getstring(User *nc, int index); +E const char *getstring(const User *nc, int index); E const char *getstring(int index); /**** log.c ****/ @@ -343,8 +343,8 @@ E void send_cmd(const Anope::string &source, const char *fmt, ...) FORMAT(printf E void notice_server(const Anope::string &source, const Server *s, const char *fmt, ...) FORMAT(printf, 3, 4); -E void notice_lang(const Anope::string &source, User *dest, int message, ...); // MARK_DEPRECATED; -E void notice_help(const Anope::string &source, User *dest, int message, ...); // MARK_DEPRECATED; +E void notice_lang(const Anope::string &source, const User *dest, int message, ...); // MARK_DEPRECATED; +E void notice_help(const Anope::string &source, const User *dest, int message, ...); // MARK_DEPRECATED; /**** sessions.c ****/ |
