diff options
Diffstat (limited to 'src')
28 files changed, 47 insertions, 49 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 53a48c469..fdf0f76e1 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -396,10 +396,10 @@ bool Channel::CheckBan(User* user, const std::string& mask) return false; const std::string nickIdent = user->nick + "!" + user->ident; - std::string prefix = mask.substr(0, at); + std::string prefix(mask, 0, at); if (InspIRCd::Match(nickIdent, prefix, NULL)) { - std::string suffix = mask.substr(at + 1); + std::string suffix(mask, at + 1); if (InspIRCd::Match(user->host, suffix, NULL) || InspIRCd::Match(user->dhost, suffix, NULL) || InspIRCd::MatchCIDR(user->GetIPString(), suffix, NULL)) diff --git a/src/cidr.cpp b/src/cidr.cpp index 8d199353d..250ad9c69 100644 --- a/src/cidr.cpp +++ b/src/cidr.cpp @@ -53,8 +53,8 @@ bool irc::sockets::MatchCIDR(const std::string &address, const std::string &cidr } else { - address_copy = address.substr(username_addr_pos + 1); - cidr_copy = cidr_mask.substr(username_mask_pos + 1); + address_copy.assign(address, username_addr_pos + 1, std::string::npos); + cidr_copy.assign(cidr_mask, username_mask_pos + 1, std::string::npos); } } else diff --git a/src/coremods/core_oper/cmd_rehash.cpp b/src/coremods/core_oper/cmd_rehash.cpp index 48dfa6fb1..19d2fa8c2 100644 --- a/src/coremods/core_oper/cmd_rehash.cpp +++ b/src/coremods/core_oper/cmd_rehash.cpp @@ -55,7 +55,7 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use // the leading "-" is optional; remove it if present. if (param[0] == '-') - param = param.substr(1); + param.erase(param.begin()); FOREACH_MOD(OnModuleRehash, (user, param)); return CMD_SUCCESS; diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp index 966c4a790..7464e0527 100644 --- a/src/coremods/core_whois.cpp +++ b/src/coremods/core_whois.cpp @@ -96,7 +96,7 @@ void CommandWhois::SplitChanList(User* source, User* dest, const std::string& cl line = prefix.str(); } - line.append(cl.substr(start, pos - start + 1)); + line.append(cl, start, pos - start + 1); } if (line.length() != prefix.str().length()) diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 46981e703..42e25f8f6 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -268,7 +268,7 @@ bool irc::tokenstream::GetToken(std::string &token) /* This is the last parameter */ if (token[0] == ':' && !first) { - token = token.substr(1); + token.erase(token.begin()); if (!StreamEnd()) { token += ' '; @@ -332,7 +332,7 @@ bool irc::sepstream::GetToken(std::string &token) if (p == std::string::npos) p = this->tokens.length(); - token = this->tokens.substr(this->pos, p - this->pos); + token.assign(tokens, this->pos, p - this->pos); this->pos = p + 1; return true; @@ -412,10 +412,9 @@ long irc::portparser::GetToken() std::string::size_type dash = x.rfind('-'); if (dash != std::string::npos) { - std::string sbegin = x.substr(0, dash); - std::string send = x.substr(dash+1, x.length()); + std::string sbegin(x, 0, dash); range_begin = atoi(sbegin.c_str()); - range_end = atoi(send.c_str()); + range_end = atoi(x.c_str()+dash+1); if ((range_begin > 0) && (range_end > 0) && (range_begin < 65536) && (range_end < 65536) && (range_begin < range_end)) { diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 494422075..886130f1b 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -150,9 +150,8 @@ bool StreamSocket::GetNextLine(std::string& line, char delim) std::string::size_type i = recvq.find(delim); if (i == std::string::npos) return false; - line = recvq.substr(0, i); - // TODO is this the most efficient way to split? - recvq = recvq.substr(i + 1); + line.assign(recvq, 0, i); + recvq.erase(0, i + 1); return true; } @@ -299,7 +298,7 @@ void StreamSocket::DoWrite() else if (rv < itemlen) { SocketEngine::ChangeEventMask(this, FD_WANT_FAST_WRITE | FD_WRITE_WILL_BLOCK); - front = front.substr(rv); + front.erase(0, rv); sendq_len -= rv; return; } @@ -378,7 +377,7 @@ void StreamSocket::DoWrite() else { // stopped in the middle of this string - front = front.substr(rv); + front.erase(0, rv); rv = 0; } } diff --git a/src/mode.cpp b/src/mode.cpp index 335bb85ce..671b5d854 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -218,7 +218,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode std::string& parameter = mcitem.param; // crop mode parameter size to 250 characters if (parameter.length() > 250 && adding) - parameter = parameter.substr(0, 250); + parameter.erase(250); ModResult MOD_RESULT; FIRST_MOD_RESULT(OnRawMode, MOD_RESULT, (user, chan, mh, parameter, adding)); diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp index 0f8070cb4..6738c046e 100644 --- a/src/modes/cmode_k.cpp +++ b/src/modes/cmode_k.cpp @@ -52,7 +52,7 @@ ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, s channel->SetMode(this, adding); if (adding) { - parameter = parameter.substr(0, 32); + parameter.erase(32); ext.set(channel, parameter); } else diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 74b66d2de..be642a79d 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -909,7 +909,7 @@ info_done_dealloc: } else if (ret > 0) { - sendq = sendq.substr(ret); + sendq.erase(0, ret); SocketEngine::ChangeEventMask(user, FD_WANT_SINGLE_WRITE); return 0; } diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index a0c30bb9e..b38478d6d 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -641,7 +641,7 @@ class OpenSSLIOHook : public SSLIOHook } else if (ret > 0) { - buffer = buffer.substr(ret); + buffer.erase(0, ret); SocketEngine::ChangeEventMask(user, FD_WANT_SINGLE_WRITE); return 0; } diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 20d3f5c45..5b3979179 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -148,7 +148,7 @@ class ModuleAlias : public Module return MOD_RES_PASSTHRU; /* The parameters for the command in their original form, with the command stripped off */ - std::string compare = original_line.substr(command.length()); + std::string compare(original_line, command.length()); while (*(compare.c_str()) == ' ') compare.erase(compare.begin()); @@ -212,7 +212,7 @@ class ModuleAlias : public Module return; /* The parameters for the command in their original form, with the command stripped off */ - std::string compare = text.substr(scommand.length() + 1); + std::string compare(text, scommand.length() + 1); while (*(compare.c_str()) == ' ') compare.erase(compare.begin()); diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp index 801cf6c74..2b9c2e1c2 100644 --- a/src/modules/m_autoop.cpp +++ b/src/modules/m_autoop.cpp @@ -47,7 +47,7 @@ class AutoOpList : public ListModeBase if (pos == 0 || pos == std::string::npos) return adding ? MOD_RES_DENY : MOD_RES_PASSTHRU; unsigned int mylevel = channel->GetPrefixValue(source); - std::string mid = parameter.substr(0, pos); + std::string mid(parameter, 0, pos); PrefixMode* mh = FindMode(mid); if (adding && !mh) diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index f6e7ea40e..a0929a0d0 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -65,7 +65,7 @@ class HistoryMode : public ParamMode<HistoryMode, SimpleExtItem<HistoryList> > if (colon == std::string::npos) return MODEACTION_DENY; - std::string duration = parameter.substr(colon+1); + std::string duration(parameter, colon+1); if ((IS_LOCAL(source)) && ((duration.length() > 10) || (!IsValidDuration(duration)))) return MODEACTION_DENY; diff --git a/src/modules/m_channelban.cpp b/src/modules/m_channelban.cpp index 4d3f80e36..189c0d0bc 100644 --- a/src/modules/m_channelban.cpp +++ b/src/modules/m_channelban.cpp @@ -32,12 +32,12 @@ class ModuleBadChannelExtban : public Module { if ((mask.length() > 2) && (mask[0] == 'j') && (mask[1] == ':')) { - std::string rm = mask.substr(2); + std::string rm(mask, 2); char status = 0; ModeHandler* mh = ServerInstance->Modes->FindPrefix(rm[0]); if (mh) { - rm = mask.substr(3); + rm.assign(mask, 3, std::string::npos); status = mh->GetModeChar(); } for (User::ChanList::iterator i = user->chans.begin(); i != user->chans.end(); i++) diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 1b838be5c..7627ba8c7 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -101,7 +101,7 @@ class CommandDccallow : public Command } } - std::string nick = parameters[0].substr(1); + std::string nick(parameters[0], 1); User *target = ServerInstance->FindNickOnly(nick); if ((target) && (!IS_SERVER(target)) && (!target->quitting) && (target->registered == REG_ALL)) diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp index 2d06b73a0..076445644 100644 --- a/src/modules/m_exemptchanops.cpp +++ b/src/modules/m_exemptchanops.cpp @@ -36,7 +36,7 @@ class ExemptChanOps : public ListModeBase return false; } - std::string restriction = word.substr(0, p); + std::string restriction(word, 0, p); // If there is a '-' in the restriction string ignore it and everything after it // to support "auditorium-vis" and "auditorium-see" in m_auditorium p = restriction.find('-'); @@ -98,7 +98,7 @@ class ExemptHandler : public HandlerBase3<ModResult, User*, Channel*, const std: if (pos == std::string::npos) continue; if (!i->mask.compare(0, pos, restriction)) - minmode = (*i).mask.substr(pos + 1); + minmode.assign(i->mask, pos + 1, std::string::npos); } } diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index a4452c9c0..bbd9f1275 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -269,7 +269,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru continue; } - std::string cheader = reqbuffer.substr(hbegin, hend - hbegin); + std::string cheader(reqbuffer, hbegin, hend - hbegin); std::string::size_type fieldsep = cheader.find(':'); if ((fieldsep == std::string::npos) || (fieldsep == 0) || (fieldsep == cheader.length() - 1)) @@ -300,7 +300,7 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru if (reqbuffer.length() >= postsize) { - postdata = reqbuffer.substr(0, postsize); + postdata.assign(reqbuffer, 0, postsize); reqbuffer.erase(0, postsize); } else if (!reqbuffer.empty()) diff --git a/src/modules/m_ldapauth.cpp b/src/modules/m_ldapauth.cpp index e89ce4949..eee357ec0 100644 --- a/src/modules/m_ldapauth.cpp +++ b/src/modules/m_ldapauth.cpp @@ -64,7 +64,7 @@ class BindInterface : public LDAPInterface while (i < text.length() - 1 && isalpha(text[i + 1])) ++i; - std::string key = text.substr(start, (i - start) + 1); + std::string key(start, (i - start) + 1); result.append(replacements[key]); } else @@ -90,8 +90,8 @@ class BindInterface : public LDAPInterface if (pos == std::string::npos) // malformed continue; - std::string key = dnPart.substr(0, pos); - std::string value = dnPart.substr(pos + 1, dnPart.length() - pos + 1); // +1s to skip the = itself + std::string key(dnPart, 0, pos); + std::string value(dnPart, pos + 1, dnPart.length() - pos + 1); // +1s to skip the = itself dnParts[key] = value; } diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp index 19dff1a8b..1735df924 100644 --- a/src/modules/m_namedmodes.cpp +++ b/src/modules/m_namedmodes.cpp @@ -138,8 +138,8 @@ class ModuleNamedModes : public Module std::string::size_type eq = name.find('='); if (eq != std::string::npos) { - value = name.substr(eq + 1); - name = name.substr(0, eq); + value.assign(name, eq + 1, std::string::npos); + name.erase(eq); } ModeHandler* mh = ServerInstance->Modes->FindMode(name, MODETYPE_CHANNEL); diff --git a/src/modules/m_password_hash.cpp b/src/modules/m_password_hash.cpp index 3cdd2b3ce..09cdbb402 100644 --- a/src/modules/m_password_hash.cpp +++ b/src/modules/m_password_hash.cpp @@ -36,7 +36,7 @@ class CommandMkpasswd : public Command { if (!algo.compare(0, 5, "hmac-", 5)) { - std::string type = algo.substr(5); + std::string type(algo, 5); HashProvider* hp = ServerInstance->Modules->FindDataService<HashProvider>("hash/" + type); if (!hp) { @@ -91,7 +91,7 @@ class ModuleOperHash : public Module { if (!hashtype.compare(0, 5, "hmac-", 5)) { - std::string type = hashtype.substr(5); + std::string type(hashtype, 5); HashProvider* hp = ServerInstance->Modules->FindDataService<HashProvider>("hash/" + type); if (!hp) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 7298d77e1..22de0ac8b 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -134,7 +134,7 @@ class CommandSilence : public Command else if (parameters.size() > 0) { // one or more parameters, add or delete entry from the list (only the first parameter is used) - std::string mask = parameters[0].substr(1); + std::string mask(parameters[0], 1); char action = parameters[0][0]; // Default is private and notice so clients do not break int pattern = CompilePattern("pn"); diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp index f27fe8889..047808c29 100644 --- a/src/modules/m_spanningtree/capab.cpp +++ b/src/modules/m_spanningtree/capab.cpp @@ -386,8 +386,8 @@ bool TreeSocket::Capab(const parameterlist ¶ms) std::string::size_type equals = item.find('='); if (equals != std::string::npos) { - std::string var = item.substr(0, equals); - std::string value = item.substr(equals+1, item.length()); + std::string var(item, 0, equals); + std::string value(item, equals+1); capab->CapKeys[var] = value; } } diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp index 127907836..c2ee940fc 100644 --- a/src/modules/m_spanningtree/compat.cpp +++ b/src/modules/m_spanningtree/compat.cpp @@ -46,7 +46,7 @@ void TreeSocket::WriteLine(const std::string& original_line) std::string line = original_line; std::string::size_type a = line.find(' '); std::string::size_type b = line.find(' ', a + 1); - std::string command = line.substr(a + 1, b-a-1); + std::string command(line, a + 1, b-a-1); // now try to find a translation entry // TODO a more efficient lookup method will be needed later if (proto_version < 1205) @@ -68,7 +68,7 @@ void TreeSocket::WriteLine(const std::string& original_line) { // No TS or modes in the command // :22DAAAAAB IJOIN #chan - const std::string channame = line.substr(b+1, c-b-1); + const std::string channame(line, b+1, c-b-1); Channel* chan = ServerInstance->FindChan(channame); if (!chan) return; diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index 0695ce632..ae98be946 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -89,7 +89,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm if (ServerInstance->Modes->FindPrefix(dest[0])) { pfx = dest[0]; - dest = dest.substr(1); + dest.erase(dest.begin()); } if (dest[0] == '#') { diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index d7c6332f2..1c624f5c4 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -81,7 +81,7 @@ void CommandServer::HandleExtra(TreeServer* newserver, const std::vector<std::st if (p != std::string::npos) { key.erase(p); - val = prop.substr(p+1); + val.assign(prop, p+1, std::string::npos); } if (key == "burst") diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 1a8bdd06c..d2fec0118 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -177,7 +177,7 @@ void TreeSocket::OnDataReady() { std::string::size_type rline = line.find('\r'); if (rline != std::string::npos) - line = line.substr(0,rline); + line.erase(rline); if (line.find('\0') != std::string::npos) { SendError("Read null character from socket"); diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 25b8e3b71..1f98f7819 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -47,7 +47,7 @@ void TreeSocket::Split(const std::string& line, std::string& prefix, std::string if (prefix[0] == ':') { - prefix = prefix.substr(1); + prefix.erase(prefix.begin()); if (prefix.empty()) { diff --git a/src/users.cpp b/src/users.cpp index 9dcbcae0c..34986a183 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -277,7 +277,7 @@ void UserIOHandler::OnDataReady() return; eol_found: // just found a newline. Terminate the string, and pull it out of recvq - recvq = recvq.substr(qpos); + recvq.erase(0, qpos); // TODO should this be moved to when it was inserted in recvq? ServerInstance->stats.Recv += qpos; @@ -764,7 +764,7 @@ void LocalUser::Write(const std::string& text) if (text.length() > ServerInstance->Config->Limits.MaxLine - 2) { // this should happen rarely or never. Crop the string at 512 and try again. - std::string try_again = text.substr(0, ServerInstance->Config->Limits.MaxLine - 2); + std::string try_again(0, ServerInstance->Config->Limits.MaxLine - 2); Write(try_again); return; } |