summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-07-09 19:49:10 +0200
committerattilamolnar <attilamolnar@hush.com>2013-08-27 18:32:32 +0200
commitb55c842c9d8730e50865fb7dd98bce4aa85af0d7 (patch)
treefa975f44064f3a19a9568e5995788514bdb5e538
parent00cd97160ae8909ca12b8807a8114cad1f6a06b1 (diff)
m_permchannels Construct the final line that will be saved in a std::string in WriteDatabase()
-rw-r--r--src/modules/m_permchannels.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp
index a59518b28..bd65c5822 100644
--- a/src/modules/m_permchannels.cpp
+++ b/src/modules/m_permchannels.cpp
@@ -51,13 +51,13 @@ static bool WriteDatabase()
fputs("# Permchannels DB\n# This file is autogenerated; any changes will be overwritten!\n<config format=\"compat\">\n", f);
// Now, let's write.
+ std::string line;
for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); i++)
{
Channel* chan = i->second;
if (!chan->IsModeSet('P'))
continue;
- char line[1024];
const char* items[] =
{
"<permchannels channel=",
@@ -69,8 +69,9 @@ static bool WriteDatabase()
">\n"
};
- int lpos = 0, item = 0, ipos = 0;
- while (lpos < 1022 && item < 7)
+ line.clear();
+ int item = 0, ipos = 0;
+ while (item < 7)
{
char c = items[item][ipos++];
if (c == 0)
@@ -82,12 +83,14 @@ static bool WriteDatabase()
}
else if (c == '\\' || c == '"')
{
- line[lpos++] = '\\';
+ line += '\\';
}
- line[lpos++] = c;
+ line += c;
}
- line[--lpos] = 0;
- fputs(line, f);
+
+ // Erase last '"'
+ line.erase(line.end()-1);
+ fputs(line.c_str(), f);
}
int write_error = 0;