From b55c842c9d8730e50865fb7dd98bce4aa85af0d7 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Tue, 9 Jul 2013 19:49:10 +0200 Subject: m_permchannels Construct the final line that will be saved in a std::string in WriteDatabase() --- src/modules/m_permchannels.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/modules/m_permchannels.cpp') 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\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[] = { "\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; -- cgit v1.3.1-10-gc9f91