summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-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;