summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hashcomp.cpp10
-rw-r--r--src/modules/m_cap.cpp13
-rw-r--r--src/modules/m_operlog.cpp4
-rw-r--r--src/modules/m_spanningtree/capab.cpp2
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp6
5 files changed, 14 insertions, 21 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 06b3ce669..3f3754884 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -397,14 +397,14 @@ int irc::modestacker::GetStackedLine(std::vector<std::string> &result, int max_l
return n;
}
-irc::stringjoiner::stringjoiner(const std::string& separator, const std::vector<std::string>& sequence, unsigned int begin, unsigned int end)
+irc::stringjoiner::stringjoiner(const std::vector<std::string>& sequence)
{
- if (end < begin)
+ if (sequence.empty())
return; // nothing to do here
- for (unsigned int v = begin; v < end; v++)
- joined.append(sequence[v]).append(separator);
- joined.append(sequence[end]);
+ for (std::vector<std::string>::const_iterator i = sequence.begin(); i != sequence.end(); ++i)
+ joined.append(*i).push_back(' ');
+ joined.erase(joined.end()-1);
}
irc::portparser::portparser(const std::string &source, bool allow_overlapped)
diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp
index 1d165f935..e5d16a6da 100644
--- a/src/modules/m_cap.cpp
+++ b/src/modules/m_cap.cpp
@@ -74,13 +74,13 @@ class CommandCAP : public Command
if (Data.ack.size() > 0)
{
- std::string AckResult = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
+ std::string AckResult = irc::stringjoiner(Data.ack).GetJoined();
user->WriteServ("CAP %s ACK :%s", user->nick.c_str(), AckResult.c_str());
}
if (Data.wanted.size() > 0)
{
- std::string NakResult = irc::stringjoiner(" ", Data.wanted, 0, Data.wanted.size() - 1).GetJoined();
+ std::string NakResult = irc::stringjoiner(Data.wanted).GetJoined();
user->WriteServ("CAP %s NAK :%s", user->nick.c_str(), NakResult.c_str());
}
}
@@ -95,10 +95,7 @@ class CommandCAP : public Command
reghold.set(user, 1);
Data.Send();
- std::string Result;
- if (Data.wanted.size() > 0)
- Result = irc::stringjoiner(" ", Data.wanted, 0, Data.wanted.size() - 1).GetJoined();
-
+ std::string Result = irc::stringjoiner(Data.wanted).GetJoined();
user->WriteServ("CAP %s %s :%s", user->nick.c_str(), subcommand.c_str(), Result.c_str());
}
else if (subcommand == "CLEAR")
@@ -108,9 +105,7 @@ class CommandCAP : public Command
reghold.set(user, 1);
Data.Send();
- std::string Result;
- if (!Data.ack.empty())
- Result = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
+ std::string Result = irc::stringjoiner(Data.ack).GetJoined();
user->WriteServ("CAP %s ACK :%s", user->nick.c_str(), Result.c_str());
}
else
diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp
index 759a9e3b8..6a7fb9a63 100644
--- a/src/modules/m_operlog.cpp
+++ b/src/modules/m_operlog.cpp
@@ -57,9 +57,7 @@ class ModuleOperLog : public Module
Command* thiscommand = ServerInstance->Parser->GetHandler(command);
if ((thiscommand) && (thiscommand->flags_needed == 'o'))
{
- std::string line;
- if (!parameters.empty())
- line = irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined();
+ std::string line = irc::stringjoiner(parameters).GetJoined();
std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + line;
ServerInstance->Logs->Log("m_operlog", LOG_DEFAULT, "OPERLOG: " + msg);
if (tosnomask)
diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp
index fa10c79fe..1ca5b982c 100644
--- a/src/modules/m_spanningtree/capab.cpp
+++ b/src/modules/m_spanningtree/capab.cpp
@@ -66,7 +66,7 @@ static std::string BuildModeList(ModeType type)
}
}
sort(modes.begin(), modes.end());
- irc::stringjoiner line(" ", modes, 0, modes.size() - 1);
+ irc::stringjoiner line(modes);
return line.GetJoined();
}
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 1b3b9dae2..42fb708a9 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -472,7 +472,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
if (!cmd)
{
- irc::stringjoiner pmlist(" ", params, 0, params.size() - 1);
+ irc::stringjoiner pmlist(params);
ServerInstance->Logs->Log("m_spanningtree", LOG_SPARSE, "Unrecognised S2S command :%s %s %s",
who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
SendError("Unrecognised command '" + command + "' -- possibly loaded mismatched modules");
@@ -481,7 +481,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
if (params.size() < cmd->min_params)
{
- irc::stringjoiner pmlist(" ", params, 0, params.size() - 1);
+ irc::stringjoiner pmlist(params);
ServerInstance->Logs->Log("m_spanningtree", LOG_SPARSE, "Insufficient parameters for S2S command :%s %s %s",
who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
SendError("Insufficient parameters for command '" + command + "'");
@@ -500,7 +500,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
if (res == CMD_INVALID)
{
- irc::stringjoiner pmlist(" ", params, 0, params.size() - 1);
+ irc::stringjoiner pmlist(params);
ServerInstance->Logs->Log("m_spanningtree", LOG_SPARSE, "Error handling S2S command :%s %s %s",
who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
SendError("Error handling '" + command + "' -- possibly loaded mismatched modules");