diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-07-09 19:49:10 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-08-27 18:32:32 +0200 |
commit | b55c842c9d8730e50865fb7dd98bce4aa85af0d7 (patch) | |
tree | fa975f44064f3a19a9568e5995788514bdb5e538 /src/modules | |
parent | 00cd97160ae8909ca12b8807a8114cad1f6a06b1 (diff) |
m_permchannels Construct the final line that will be saved in a std::string in WriteDatabase()
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_permchannels.cpp | 17 |
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; |