Mercurial > irccd
changeset 23:03068f5ed79d
Misc: various style issues, #419
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 14 Feb 2016 16:15:48 +0100 |
parents | 23d59afec277 |
children | 392778b6d3c9 |
files | common/directory.cpp common/filesystem.cpp common/ini.cpp common/ini.h common/json.cpp common/json.h common/logger.cpp common/options.cpp common/options.h common/path.cpp common/signals.h common/system.cpp common/util.cpp irccd/config.cpp irccd/irccd.cpp irccd/irccd.h irccd/js-file.cpp irccd/js-file.h irccd/js-plugin.cpp irccd/js-server.cpp irccd/js-timer.cpp irccd/js-util.cpp irccd/js.cpp irccd/js.h irccd/plugin.cpp irccd/rule.cpp irccd/server-state.cpp irccd/timer.cpp |
diffstat | 28 files changed, 281 insertions(+), 354 deletions(-) [+] |
line wrap: on
line diff
--- a/common/directory.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/common/directory.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -57,7 +57,7 @@ return errmsg; } -} +} // !namespace void Directory::systemLoad(const std::string &path, int flags) { @@ -108,7 +108,7 @@ struct dirent *ent; if ((dp = opendir(path.c_str())) == nullptr) - throw std::runtime_error(strerror(errno)); + throw std::runtime_error(std::strerror(errno)); while ((ent = readdir(dp)) != nullptr) { DirectoryEntry entry;
--- a/common/filesystem.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/common/filesystem.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -42,15 +42,15 @@ namespace fs { #if defined(IRCCD_SYSTEM_WINDOWS) -const char Separator{'\\'}; +const char Separator('\\'); #else -const char Separator{'/'}; +const char Separator('/'); #endif std::string baseName(std::string path) { #if defined(IRCCD_SYSTEM_WINDOWS) - size_t pos; + std::size_t pos; pos = path.find_last_of('\\'); if (pos == std::string::npos) @@ -129,7 +129,7 @@ oss << "mkdir: "; - for (size_t i = 0; i < dir.length(); ++i) { + for (std::size_t i = 0; i < dir.length(); ++i) { if (dir[i] != '/' && dir[i] != '\\') continue;
--- a/common/ini.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/common/ini.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -127,19 +127,16 @@ /* Read section name */ ++ it; while (it != end && *it != ']') { - if (*it == '\n') { - throw Error{line, column, "section not terminated, missing ']'"}; - } - if (isReserved(*it)) { - throw Error{line, column, "section name expected after '[', got '" + std::string(1, *it) + "'"}; - } + if (*it == '\n') + throw Error(line, column, "section not terminated, missing ']'"); + if (isReserved(*it)) + throw Error(line, column, "section name expected after '[', got '" + std::string(1, *it) + "'"); ++ column; value += *it++; } - if (it == end) { - throw Error{line, column, "section name expected after '[', got <EOF>"}; - } + if (it == end) + throw Error(line, column, "section name expected after '[', got <EOF>"); /* Remove ']' */ ++ it; @@ -167,9 +164,8 @@ value += *it++; } - if (it == end) { - throw Error{line, column, "undisclosed '" + std::string(1, quote) + "', got <EOF>"}; - } + if (it == end) + throw Error(line, column, "undisclosed '" + std::string(1, quote) + "', got <EOF>"); /* Remove quote */ ++ it; @@ -206,9 +202,8 @@ include += *it++; } - if (include != "include") { - throw Error{line, column, "expected include after '@' token"}; - } + if (include != "include") + throw Error(line, column, "expected include after '@' token"); list.push_back({ Token::Include, line, save }); } @@ -220,25 +215,24 @@ int column = 0; while (it != end) { - if (*it == '\n') { + if (*it == '\n') analyzeLine(line, column, it); - } else if (*it == '#') { + else if (*it == '#') analyzeComment(column, it, end); - } else if (*it == '[') { + else if (*it == '[') analyzeSection(list, line, column, it, end); - } else if (*it == '=') { + else if (*it == '=') analyzeAssign(list, line, column, it); - } else if (isSpace(*it)) { + else if (isSpace(*it)) analyzeSpaces(column, it, end); - } else if (*it == '@') { + else if (*it == '@') analyzeInclude(list, line, column, it, end); - } else if (isQuote(*it)) { + else if (isQuote(*it)) analyzeQuotedWord(list, line, column, it, end); - } else if (isList(*it)) { + else if (isList(*it)) analyzeList(list, line, column, it); - } else { + else analyzeWord(list, line, column, it, end); - } } return list; @@ -261,9 +255,8 @@ switch (it->type()) { case Token::Comma: /* Previous must be a word */ - if (it[-1].type() != Token::Word && it[-1].type() != Token::QuotedWord) { - throw Error{it->line(), it->column(), "unexpected comma after '" + it[-1].value() + "'"}; - } + if (it[-1].type() != Token::Word && it[-1].type() != Token::QuotedWord) + throw Error(it->line(), it->column(), "unexpected comma after '" + it[-1].value() + "'"); ++ it; break; @@ -272,14 +265,13 @@ option.push_back((it++)->value()); break; default: - throw Error{it->line(), it->column(), "unexpected '" + it[-1].value() + "' in list construct"}; + throw Error(it->line(), it->column(), "unexpected '" + it[-1].value() + "' in list construct"); break; } } - if (it == end) { - throw Error{save->line(), save->column(), "unterminated list construct"}; - } + if (it == end) + throw Error(save->line(), save->column(), "unterminated list construct"); /* Remove ) */ ++ it; @@ -287,25 +279,22 @@ void parseOption(Section &sc, TokenIterator &it, TokenIterator end) { - Option option{it->value()}; + Option option(it->value()); TokenIterator save = it; /* No '=' or something else? */ - if (++it == end) { - throw Error{save->line(), save->column(), "expected '=' assignment, got <EOF>"}; - } - if (it->type() != Token::Assign) { - throw Error{it->line(), it->column(), "expected '=' assignment, got " + it->value()}; - } + if (++it == end) + throw Error(save->line(), save->column(), "expected '=' assignment, got <EOF>"); + if (it->type() != Token::Assign) + throw Error(it->line(), it->column(), "expected '=' assignment, got " + it->value()); /* Empty options are allowed so just test for words */ if (++it != end) { - if (it->type() == Token::Word || it->type() == Token::QuotedWord) { + if (it->type() == Token::Word || it->type() == Token::QuotedWord) parseOptionValueSimple(option, it); - } else if (it->type() == Token::ListBegin) { + else if (it->type() == Token::ListBegin) parseOptionValueList(option, it, end); - } } sc.push_back(std::move(option)); @@ -315,17 +304,12 @@ { TokenIterator save = it; - if (++it == end) { - throw Error{save->line(), save->column(), "expected file name after '@include' statement, got <EOF>"}; - } - - if (it->type() != Token::Word && it->type() != Token::QuotedWord) { - throw Error{it->line(), it->column(), "expected file name after '@include' statement, got " + it->value()}; - } - - if (doc.path().empty()) { - throw Error{it->line(), it->column(), "'@include' statement invalid with buffer documents"}; - } + if (++it == end) + throw Error(save->line(), save->column(), "expected file name after '@include' statement, got <EOF>"); + if (it->type() != Token::Word && it->type() != Token::QuotedWord) + throw Error(it->line(), it->column(), "expected file name after '@include' statement, got " + it->value()); + if (doc.path().empty()) + throw Error(it->line(), it->column(), "'@include' statement invalid with buffer documents"); std::string value = (it++)->value(); std::string file; @@ -340,25 +324,23 @@ file = value; } - Document child{File{file}}; + Document child(File{file}); - for (const auto &sc : child) { + for (const auto &sc : child) doc.push_back(sc); - } } void parseSection(Document &doc, TokenIterator &it, TokenIterator end) { - Section sc{it->value()}; + Section sc(it->value()); /* Skip [section] */ ++ it; /* Read until next section */ while (it != end && it->type() != Token::Section) { - if (it->type() != Token::Word) { - throw Error{it->line(), it->column(), "unexpected token '" + it->value() + "' in section definition"}; - } + if (it->type() != Token::Word) + throw Error(it->line(), it->column(), "unexpected token '" + it->value() + "' in section definition"); parseOption(sc, it, end); } @@ -381,7 +363,7 @@ parseSection(doc, it, end); break; default: - throw Error{it->line(), it->column(), "unexpected '" + it->value() + "' on root document"}; + throw Error(it->line(), it->column(), "unexpected '" + it->value() + "' on root document"); } } } @@ -394,38 +376,36 @@ Tokens Document::analyze(const File &file) { - std::fstream stream{file.path}; + std::fstream stream(file.path); - if (!stream) { - throw std::runtime_error{std::strerror(errno)}; - } + if (!stream) + throw std::runtime_error(std::strerror(errno)); - std::istreambuf_iterator<char> it{stream}; - std::istreambuf_iterator<char> end{}; + std::istreambuf_iterator<char> it(stream); + std::istreambuf_iterator<char> end; return ::analyze(it, end); } Tokens Document::analyze(const Buffer &buffer) { - std::istringstream stream{buffer.text}; - std::istreambuf_iterator<char> it{stream}; - std::istreambuf_iterator<char> end{}; + std::istringstream stream(buffer.text); + std::istreambuf_iterator<char> it(stream); + std::istreambuf_iterator<char> end; return ::analyze(it, end); } Document::Document(const File &file) - : m_path{file.path} + : m_path(file.path) { /* Update path */ auto pos = m_path.find_last_of("/\\"); - if (pos != std::string::npos) { + if (pos != std::string::npos) m_path.erase(pos); - } else { + else m_path = "."; - } parse(*this, analyze(file)); } @@ -437,10 +417,9 @@ void Document::dump(const Tokens &tokens) { - for (const Token &token: tokens) { + for (const Token &token: tokens) // TODO: add better description std::cout << token.line() << ":" << token.column() << ": " << token.value() << std::endl; - } } } // !ini
--- a/common/ini.h Fri Feb 12 21:02:28 2016 +0100 +++ b/common/ini.h Sun Feb 14 16:15:48 2016 +0100 @@ -58,9 +58,9 @@ * @param m the message */ inline Error(int l, int c, std::string m) noexcept - : m_line{l} - , m_column{c} - , m_message{std::move(m)} + : m_line(l) + , m_column(c) + , m_message(std::move(m)) { } @@ -135,9 +135,9 @@ * @param value the value */ Token(Type type, int line, int column, std::string value = "") noexcept - : m_type{type} - , m_line{line} - , m_column{column} + : m_type(type) + , m_line(line) + , m_column(column) { switch (type) { case Include: @@ -228,8 +228,8 @@ * @param value the value */ inline Option(std::string key) noexcept - : std::vector<std::string>{} - , m_key{std::move(key)} + : std::vector<std::string>() + , m_key(std::move(key)) { } @@ -240,7 +240,7 @@ * @param value the value */ inline Option(std::string key, std::string value) noexcept - : m_key{std::move(key)} + : m_key(std::move(key)) { push_back(std::move(value)); } @@ -252,8 +252,8 @@ * @param values the values */ inline Option(std::string key, std::vector<std::string> values) noexcept - : std::vector<std::string>{std::move(values)} - , m_key{std::move(key)} + : std::vector<std::string>(std::move(values)) + , m_key(std::move(key)) { } @@ -295,7 +295,7 @@ * @param key the key */ inline Section(std::string key) noexcept - : m_key{std::move(key)} + : m_key(std::move(key)) { }
--- a/common/json.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/common/json.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -33,37 +33,32 @@ Value readValue(json_t *v) { - if (json_is_null(v)) { - return Value{nullptr}; - } - if (json_is_string(v)) { - return Value{json_string_value(v)}; - } - if (json_is_real(v)) { - return Value{json_number_value(v)}; - } - if (json_is_integer(v)) { - return Value{static_cast<int>(json_integer_value(v))}; - } - if (json_is_boolean(v)) { - return Value{json_boolean_value(v)}; - } + if (json_is_null(v)) + return Value(nullptr); + if (json_is_string(v)) + return Value(json_string_value(v)); + if (json_is_real(v)) + return Value(json_number_value(v)); + if (json_is_integer(v)) + return Value(static_cast<int>(json_integer_value(v))); + if (json_is_boolean(v)) + return Value(json_boolean_value(v)); if (json_is_object(v)) { - Value object{Type::Object}; + Value object(Type::Object); readObject(object, v); return object; } if (json_is_array(v)) { - Value array{Type::Array}; + Value array(Type::Array); readArray(array, v); return array; } - return Value{}; + return Value(); } void readObject(Value &parent, json_t *object) @@ -71,9 +66,8 @@ const char *key; json_t *value; - json_object_foreach(object, key, value) { + json_object_foreach(object, key, value) parent.insert(key, readValue(value)); - } } void readArray(Value &parent, json_t *array) @@ -81,9 +75,8 @@ size_t index; json_t *value; - json_array_foreach(array, index, value) { + json_array_foreach(array, index, value) parent.append(readValue(value)); - } } template <typename Func, typename... Args> @@ -92,17 +85,16 @@ json_error_t error; json_t *json = fn(std::forward<Args>(args)..., &error); - if (json == nullptr) { - throw Error{error.text, error.source, error.line, error.column, error.position}; - } + if (json == nullptr) + throw Error(error.text, error.source, error.line, error.column, error.position); Value value; if (json_is_object(json)) { - value = Value{Type::Object}; + value = Value(Type::Object); readObject(value, json); } else { - value = Value{Type::Array}; + value = Value(Type::Array); readArray(value, json); } @@ -115,11 +107,10 @@ { std::string str; - if (param < 0) { + if (param < 0) str = std::string(level, '\t'); - } else if (param > 0) { + else if (param > 0) str = std::string(param * level, ' '); - } return str; } @@ -183,7 +174,7 @@ } Value::Value(Type type) - : m_type{type} + : m_type(type) { switch (m_type) { case Type::Array: @@ -228,27 +219,24 @@ bool Value::toBool() const noexcept { - if (m_type != Type::Boolean) { + if (m_type != Type::Boolean) return false; - } return m_boolean; } double Value::toReal() const noexcept { - if (m_type != Type::Real) { + if (m_type != Type::Real) return 0; - } return m_number; } int Value::toInt() const noexcept { - if (m_type != Type::Int) { + if (m_type != Type::Int) return 0; - } return m_integer; } @@ -257,11 +245,10 @@ { std::string result; - if (m_type == Type::String) { + if (m_type == Type::String) result = m_string; - } else if (coerce) { + else if (coerce) result = toJson(); - } return result; }
--- a/common/json.h Fri Feb 12 21:02:28 2016 +0100 +++ b/common/json.h Sun Feb 14 16:15:48 2016 +0100 @@ -80,11 +80,11 @@ * @param position the position */ inline Error(std::string text, std::string source, int line, int column, int position) noexcept - : m_text{std::move(text)} - , m_source{std::move(source)} - , m_line{line} - , m_column{column} - , m_position{position} + : m_text(std::move(text)) + , m_source(std::move(source)) + , m_line(line) + , m_column(column) + , m_position(position) { } @@ -208,11 +208,10 @@ inline void increment() { - if (m_value.isObject()) { + if (m_value.isObject()) m_itm++; - } else { + else m_ita++; - } } BaseIterator(ValueType &value, ObjectIteratorType it) @@ -379,7 +378,7 @@ * Construct a null value. */ inline Value(std::nullptr_t) noexcept - : m_type{Type::Null} + : m_type(Type::Null) { } @@ -389,8 +388,8 @@ * @param value the boolean value */ inline Value(bool value) noexcept - : m_type{Type::Boolean} - , m_boolean{value} + : m_type(Type::Boolean) + , m_boolean(value) { } @@ -400,8 +399,8 @@ * @param value the value */ inline Value(int value) noexcept - : m_type{Type::Int} - , m_integer{value} + : m_type(Type::Int) + , m_integer(value) { } @@ -411,9 +410,9 @@ * @param value the C-string */ inline Value(const char *value) - : m_type{Type::String} + : m_type(Type::String) { - new (&m_string) std::string{value ? value : ""}; + new (&m_string) std::string(value ? value : ""); } /** @@ -422,8 +421,8 @@ * @param value the real value */ inline Value(double value) noexcept - : m_type{Type::Real} - , m_number{value} + : m_type(Type::Real) + , m_number(value) { } @@ -433,9 +432,9 @@ * @param value the string */ inline Value(std::string value) noexcept - : m_type{Type::String} + : m_type(Type::String) { - new (&m_string) std::string{std::move(value)}; + new (&m_string) std::string(std::move(value)); } /** @@ -445,11 +444,10 @@ * @see fromObject */ inline Value(std::map<std::string, Value> values) - : Value{Type::Object} + : Value(Type::Object) { - for (const auto &pair : values) { + for (const auto &pair : values) insert(pair.first, pair.second); - } } /** @@ -459,11 +457,10 @@ * @see fromArray */ inline Value(std::vector<Value> values) - : Value{Type::Array} + : Value(Type::Array) { - for (Value value : values) { + for (Value value : values) append(std::move(value)); - } } /** @@ -741,9 +738,8 @@ { assert(isArray() || isObject()); - if (m_type == Type::Object) { + if (m_type == Type::Object) return m_object.size(); - } return m_array.size(); } @@ -757,11 +753,10 @@ { assert(isArray() || isObject()); - if (m_type == Type::Array) { + if (m_type == Type::Array) m_array.clear(); - } else { + else m_object.clear(); - } } /* @@ -779,9 +774,8 @@ template <typename DefaultValue> inline Value valueOr(unsigned position, DefaultValue &&defaultValue) const { - if (m_type != Type::Array || position >= m_array.size()) { + if (m_type != Type::Array || position >= m_array.size()) return defaultValue; - } return m_array[position]; } @@ -797,9 +791,8 @@ template <typename DefaultValue> inline Value valueOr(unsigned position, Type type, DefaultValue &&defaultValue) const { - if (m_type != Type::Array || position >= m_array.size() || m_array[position].typeOf() != type) { + if (m_type != Type::Array || position >= m_array.size() || m_array[position].typeOf() != type) return defaultValue; - } return m_array[position]; } @@ -980,15 +973,13 @@ template <typename DefaultValue> Value valueOr(const std::string &name, DefaultValue &&defaultValue) const { - if (m_type != Type::Object) { + if (m_type != Type::Object) return defaultValue; - } auto it = m_object.find(name); - if (it == m_object.end()) { + if (it == m_object.end()) return defaultValue; - } return it->second; } @@ -1004,15 +995,13 @@ template <typename DefaultValue> Value valueOr(const std::string &name, Type type, DefaultValue &&defaultValue) const { - if (m_type != Type::Object) { + if (m_type != Type::Object) return defaultValue; - } auto it = m_object.find(name); - if (it == m_object.end() || it->second.typeOf() != type) { + if (it == m_object.end() || it->second.typeOf() != type) return defaultValue; - } return it->second; }
--- a/common/logger.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/common/logger.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -56,7 +56,7 @@ * @param level the level */ inline Buffer(Level level) noexcept - : m_level{level} + : m_level(level) { } @@ -126,17 +126,17 @@ std::unique_ptr<Interface> iface; /* Internal buffers */ -Buffer bufferInfo{Level::Info}; -Buffer bufferWarning{Level::Warning}; -Buffer bufferDebug{Level::Debug}; +Buffer bufferInfo(Level::Info); +Buffer bufferWarning(Level::Warning); +Buffer bufferDebug(Level::Debug); /* Stream outputs */ -std::ostream streamInfo{&bufferInfo}; -std::ostream streamWarning{&bufferWarning}; -std::ostream streamDebug{&bufferDebug}; +std::ostream streamInfo(&bufferInfo); +std::ostream streamWarning(&bufferWarning); +std::ostream streamDebug(&bufferDebug); /* Options */ -bool verbose{false}; +bool verbose(false); } // !namespace @@ -157,8 +157,8 @@ * -------------------------------------------------------- */ File::File(std::string normal, std::string errors) - : m_outputNormal{std::move(normal)} - , m_outputError{std::move(errors)} + : m_outputNormal(std::move(normal)) + , m_outputError(std::move(errors)) { }
--- a/common/options.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/common/options.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -54,15 +54,13 @@ auto arg = *it++; auto opt = definition.find(arg); - if (opt == definition.end()) { - throw InvalidOption{arg}; - } + if (opt == definition.end()) + throw InvalidOption(arg); /* Need argument? */ if (opt->second) { - if (it == end || isOption(*it)) { - throw MissingValue{arg}; - } + if (it == end || isOption(*it)) + throw MissingValue(arg); result.insert(std::make_pair(arg, *it++)); it = args.erase(args.begin(), it); @@ -86,15 +84,13 @@ auto arg = *it++; auto opt = definition.find(arg); - if (opt == definition.end()) { - throw InvalidOption{arg}; - } + if (opt == definition.end()) + throw InvalidOption(arg); /* Need argument? */ if (opt->second) { - if (it == end || isOption(*it)) { - throw MissingValue{arg}; - } + if (it == end || isOption(*it)) + throw MissingValue(arg); result.insert(std::make_pair(arg, *it++)); it = args.erase(args.begin(), it); @@ -120,16 +116,14 @@ auto arg = std::string{'-'} + value[i]; auto opt = definition.find(arg); - if (opt == definition.end()) { - throw InvalidOption{arg}; - } + if (opt == definition.end()) + throw InvalidOption(arg); if (opt->second) { if (i == (len - 1)) { /* End of string, get the next argument (see 2.) */ - if (++it == end || isOption(*it)) { - throw MissingValue{arg}; - } + if (++it == end || isOption(*it)) + throw MissingValue(arg); result.insert(std::make_pair(arg, *it)); toremove += 1; @@ -157,15 +151,13 @@ auto end = args.end(); while (it != end) { - if (!isOption(*it)) { + if (!isOption(*it)) break; - } - if (isLongOption(*it)) { + if (isLongOption(*it)) parseLongOption(result, args, it, end, definition); - } else { + else parseShortOption(result, args, it, end, definition); - } } return result; @@ -175,9 +167,8 @@ { std::vector<std::string> args; - for (int i = 0; i < argc; ++i) { + for (int i = 0; i < argc; ++i) args.push_back(argv[i]); - } auto before = args.size(); auto result = read(args, definition);
--- a/common/options.h Fri Feb 12 21:02:28 2016 +0100 +++ b/common/options.h Sun Feb 14 16:15:48 2016 +0100 @@ -52,9 +52,9 @@ * @param arg the argument missing */ inline InvalidOption(std::string arg) - : argument{std::move(arg)} + : argument(std::move(arg)) { - message = std::string{"invalid option: "} + argument; + message = std::string("invalid option: ") + argument; } /** @@ -88,9 +88,9 @@ * @param arg the argument that requires a value */ inline MissingValue(std::string arg) - : argument{std::move(arg)} + : argument(std::move(arg)) { - message = std::string{"missing argument for: "} + argument; + message = std::string("missing argument for: ") + argument; } /**
--- a/common/path.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/common/path.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -91,7 +91,7 @@ result.resize(size); if (!(size = GetModuleFileNameA(nullptr, &result[0], size))) - throw std::runtime_error{"GetModuleFileName error"}; + throw std::runtime_error("GetModuleFileName error"); result.resize(size); @@ -109,7 +109,7 @@ auto size = readlink("/proc/self/exe", &result[0], 2048); if (size < 0) - throw std::invalid_argument{std::strerror(errno)}; + throw std::invalid_argument(std::strerror(errno)); result.resize(size); @@ -127,7 +127,7 @@ result.resize(size); if (sysctl(mib.data(), 4, &result[0], &size, nullptr, 0) < 0) - throw std::runtime_error{std::strerror(errno)}; + throw std::runtime_error(std::strerror(errno)); result.resize(size); @@ -144,7 +144,7 @@ result.resize(size); if ((size = proc_pidpath(getpid(), &result[0], size)) == 0) - throw std::runtime_error{std::strerror(errno)}; + throw std::runtime_error(std::strerror(errno)); result.resize(size); @@ -381,9 +381,9 @@ } // !namespace #if defined(IRCCD_SYSTEM_WINDOWS) -const char Separator{';'}; +const char Separator(';'); #else -const char Separator{':'}; +const char Separator(':'); #endif void setApplicationPath(const std::string &argv0) @@ -424,9 +424,8 @@ } /* Not found in PATH? add dummy value */ - if (base.empty()) { + if (base.empty()) base = std::string(".") + fs::Separator + WITH_BINDIR + fs::Separator + "dummy"; - } } }
--- a/common/signals.h Fri Feb 12 21:02:28 2016 +0100 +++ b/common/signals.h Sun Feb 14 16:15:48 2016 +0100 @@ -50,7 +50,7 @@ * @param id the id */ inline SignalConnection(unsigned id) noexcept - : m_id{id} + : m_id(id) { } @@ -164,9 +164,8 @@ for (unsigned i : ids) { auto it = m_functions.find(i); - if (it != m_functions.end()) { + if (it != m_functions.end()) it->second(args...); - } } } };
--- a/common/system.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/common/system.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -176,7 +176,7 @@ struct utsname uts; if (uname(&uts) < 0) - throw std::runtime_error(strerror(errno)); + throw std::runtime_error(std::strerror(errno)); return std::string(uts.release); #endif @@ -190,7 +190,7 @@ struct sysinfo info; if (sysinfo(&info) < 0) - throw std::runtime_error(strerror(errno)); + throw std::runtime_error(std::strerror(errno)); return info.uptime; #elif defined(IRCCD_SYSTEM_MAC) @@ -199,7 +199,7 @@ int mib[2] = { CTL_KERN, KERN_BOOTTIME }; if (sysctl(mib, 2, &boottime, &length, nullptr, 0) < 0) - throw std::runtime_error(strerror(errno)); + throw std::runtime_error(std::strerror(errno)); time_t bsec = boottime.tv_sec, csec = time(nullptr); @@ -209,7 +209,7 @@ struct timespec ts; if (clock_gettime(CLOCK_UPTIME, &ts) < 0) - throw std::runtime_error(strerror(errno)); + throw std::runtime_error(std::strerror(errno)); return ts.tv_sec; #endif
--- a/common/util.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/common/util.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -307,7 +307,7 @@ } } - return MessagePair{result, ((iscommand) ? MessageType::Command : MessageType::Message)}; + return MessagePair(result, ((iscommand) ? MessageType::Command : MessageType::Message)); } bool isBoolean(std::string value) noexcept
--- a/irccd/config.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/config.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -330,9 +330,9 @@ ini::Section::const_iterator it; if ((it = sc.find("name")) == sc.end()) { - throw invalid_argument{"missing name"}; + throw invalid_argument("missing name"); } else if (!util::isIdentifierValid(it->value())) { - throw invalid_argument{"identity name not valid"}; + throw invalid_argument("identity name not valid"); } identity.name = it->value(); @@ -371,7 +371,7 @@ { /* Simple converter from std::vector to std::unordered_set */ auto toSet = [] (const std::vector<std::string> &v) -> std::unordered_set<std::string> { - return std::unordered_set<std::string>{v.begin(), v.end()}; + return std::unordered_set<std::string>(v.begin(), v.end()); }; RuleSet servers, channels, origins, plugins, events;
--- a/irccd/irccd.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/irccd.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -17,7 +17,6 @@ */ #include <algorithm> -#include <cassert> #include <stdexcept> #include <filesystem.h> @@ -329,7 +328,7 @@ log::debug() << " channel: " << channel << "\n"; log::debug() << " names: " << util::join(nicknames.begin(), nicknames.end(), ", ") << std::endl; - json::Value names(std::vector<json::Value>{nicknames.begin(), nicknames.end()}); + json::Value names(std::vector<json::Value>(nicknames.begin(), nicknames.end())); json::Value json = json::object({ { "event", "onNames" }, { "server", server->info().name }, @@ -638,8 +637,8 @@ client->send(object.toJson(0)); /* Connect signals */ - client->onCommand.connect(bind(&Irccd::handleTransportCommand, this, ptr, _1)); - client->onDie.connect(bind(&Irccd::handleTransportDie, this, ptr)); + client->onCommand.connect(std::bind(&Irccd::handleTransportCommand, this, ptr, _1)); + client->onDie.connect(std::bind(&Irccd::handleTransportDie, this, ptr)); /* Register it */ m_lookupTransportClients.emplace(client->handle(), move(client)); @@ -733,22 +732,22 @@ std::weak_ptr<Server> ptr(server); - server->onChannelMode.connect(bind(&Irccd::handleServerChannelMode, this, ptr, _1, _2, _3, _4)); - server->onChannelNotice.connect(bind(&Irccd::handleServerChannelNotice, this, ptr, _1, _2, _3)); - server->onConnect.connect(bind(&Irccd::handleServerConnect, this, ptr)); - server->onInvite.connect(bind(&Irccd::handleServerInvite, this, ptr, _1, _2, _3)); - server->onJoin.connect(bind(&Irccd::handleServerJoin, this, ptr, _1, _2)); - server->onKick.connect(bind(&Irccd::handleServerKick, this, ptr, _1, _2, _3, _4)); - server->onMessage.connect(bind(&Irccd::handleServerMessage, this, ptr, _1, _2, _3)); - server->onMe.connect(bind(&Irccd::handleServerMe, this, ptr, _1, _2, _3)); - server->onMode.connect(bind(&Irccd::handleServerMode, this, ptr, _1, _2)); - server->onNames.connect(bind(&Irccd::handleServerNames, this, ptr, _1, _2)); - server->onNick.connect(bind(&Irccd::handleServerNick, this, ptr, _1, _2)); - server->onNotice.connect(bind(&Irccd::handleServerNotice, this, ptr, _1, _2)); - server->onPart.connect(bind(&Irccd::handleServerPart, this, ptr, _1, _2, _3)); - server->onQuery.connect(bind(&Irccd::handleServerQuery, this, ptr, _1, _2)); - server->onTopic.connect(bind(&Irccd::handleServerTopic, this, ptr, _1, _2, _3)); - server->onWhois.connect(bind(&Irccd::handleServerWhois, this, ptr, _1)); + server->onChannelMode.connect(std::bind(&Irccd::handleServerChannelMode, this, ptr, _1, _2, _3, _4)); + server->onChannelNotice.connect(std::bind(&Irccd::handleServerChannelNotice, this, ptr, _1, _2, _3)); + server->onConnect.connect(std::bind(&Irccd::handleServerConnect, this, ptr)); + server->onInvite.connect(std::bind(&Irccd::handleServerInvite, this, ptr, _1, _2, _3)); + server->onJoin.connect(std::bind(&Irccd::handleServerJoin, this, ptr, _1, _2)); + server->onKick.connect(std::bind(&Irccd::handleServerKick, this, ptr, _1, _2, _3, _4)); + server->onMessage.connect(std::bind(&Irccd::handleServerMessage, this, ptr, _1, _2, _3)); + server->onMe.connect(std::bind(&Irccd::handleServerMe, this, ptr, _1, _2, _3)); + server->onMode.connect(std::bind(&Irccd::handleServerMode, this, ptr, _1, _2)); + server->onNames.connect(std::bind(&Irccd::handleServerNames, this, ptr, _1, _2)); + server->onNick.connect(std::bind(&Irccd::handleServerNick, this, ptr, _1, _2)); + server->onNotice.connect(std::bind(&Irccd::handleServerNotice, this, ptr, _1, _2)); + server->onPart.connect(std::bind(&Irccd::handleServerPart, this, ptr, _1, _2, _3)); + server->onQuery.connect(std::bind(&Irccd::handleServerQuery, this, ptr, _1, _2)); + server->onTopic.connect(std::bind(&Irccd::handleServerTopic, this, ptr, _1, _2, _3)); + server->onWhois.connect(std::bind(&Irccd::handleServerWhois, this, ptr, _1)); server->onDie.connect([this, ptr] () { post([=] () { auto server = ptr.lock(); @@ -763,7 +762,7 @@ m_servers.emplace(server->info().name, move(server)); } -std::shared_ptr<Server> Irccd::getServer(const string &name) const noexcept +std::shared_ptr<Server> Irccd::getServer(const std::string &name) const noexcept { auto it = m_servers.find(name); @@ -801,14 +800,14 @@ m_servers.clear(); } -void Irccd::addTransport(shared_ptr<TransportServer> ts) +void Irccd::addTransport(std::shared_ptr<TransportServer> ts) { m_lookupTransportServers.emplace(ts->handle(), ts); } #if defined(WITH_JS) -std::shared_ptr<Plugin> Irccd::getPlugin(const string &name) const noexcept +std::shared_ptr<Plugin> Irccd::getPlugin(const std::string &name) const noexcept { auto it = m_plugins.find(name); @@ -832,8 +831,8 @@ { std::weak_ptr<Plugin> ptr(plugin); - plugin->onTimerSignal.connect(bind(&Irccd::handleTimerSignal, this, ptr, _1)); - plugin->onTimerEnd.connect(bind(&Irccd::handleTimerEnd, this, ptr, _1)); + plugin->onTimerSignal.connect(std::bind(&Irccd::handleTimerSignal, this, ptr, _1)); + plugin->onTimerEnd.connect(std::bind(&Irccd::handleTimerEnd, this, ptr, _1)); /* Store reference to irccd */ plugin->context().putGlobal("\xff""\xff""irccd", js::RawPointer<Irccd>{this}); @@ -910,7 +909,7 @@ #if defined(WITH_JS) -void Irccd::handleTimerSignal(weak_ptr<Plugin> ptr, shared_ptr<Timer> timer) +void Irccd::handleTimerSignal(std::weak_ptr<Plugin> ptr, std::shared_ptr<Timer> timer) { post([this, ptr, timer] () { auto plugin = ptr.lock(); @@ -920,10 +919,10 @@ auto &ctx = plugin->context(); - js::StackAssert sa{ctx}; + js::StackAssert sa(ctx); try { - ctx.getGlobal<void>("\xff""\xff""timer-" + std::to_string(reinterpret_cast<intptr_t>(timer.get()))); + ctx.getGlobal<void>("\xff""\xff""timer-" + std::to_string(reinterpret_cast<std::intptr_t>(timer.get()))); ctx.pcall(0); ctx.pop(); } catch (const std::exception &) { @@ -932,7 +931,7 @@ }); } -void Irccd::handleTimerEnd(weak_ptr<Plugin> ptr, shared_ptr<Timer> timer) +void Irccd::handleTimerEnd(std::weak_ptr<Plugin> ptr, std::shared_ptr<Timer> timer) { post([this, ptr, timer] () { auto plugin = ptr.lock(); @@ -1017,10 +1016,10 @@ * Make a copy because the events can add other events while we are iterating it. Also lock because the timers * may alter these events too. */ - vector<Event> copy; + std::vector<Event> copy; { - lock_guard<mutex> lock(m_mutex); + std::lock_guard<mutex> lock(m_mutex); copy = move(m_events);
--- a/irccd/irccd.h Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/irccd.h Sun Feb 14 16:15:48 2016 +0100 @@ -84,13 +84,6 @@ #endif }; -class TransportEvent { -public: - std::string name; - std::weak_ptr<TransportClient> client; - std::function<std::string ()> exec; -}; - /** * Map of servers. */
--- a/irccd/js-file.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/js-file.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -477,7 +477,7 @@ std::string mode = ctx.require<std::string>(1); try { - ctx.construct(js::Pointer<File>{new File{path, mode}}); + ctx.construct(js::Pointer<File>{new File(path, mode)}); } catch (const std::exception &) { ctx.raise(SystemError()); } @@ -580,7 +580,7 @@ struct stat st; if (::stat(ctx.require<std::string>(0).c_str(), &st) < 0) - ctx.raise(SystemError{}); + ctx.raise(SystemError()); ctx.push(st);
--- a/irccd/js-file.h Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/js-file.h Sun Feb 14 16:15:48 2016 +0100 @@ -166,7 +166,7 @@ */ static inline void prototype(js::Context &ctx) { - js::StackAssert checker{ctx, 1}; + js::StackAssert sa(ctx, 1); ctx.getGlobal<void>("Irccd"); ctx.getProperty<void>(-1, "File");
--- a/irccd/js-plugin.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/js-plugin.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -38,9 +38,9 @@ try { func(*ctx.getGlobal<js::RawPointer<Irccd>>("\xff""\xff""irccd"), name); } catch (const std::out_of_range &ex) { - ctx.raise(js::ReferenceError{ex.what()}); + ctx.raise(js::ReferenceError(ex.what())); } catch (const std::exception &ex) { - ctx.raise(js::Error{ex.what()}); + ctx.raise(js::Error(ex.what())); } return nret;
--- a/irccd/js-server.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/js-server.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -399,7 +399,7 @@ try { ctx.construct(js::Shared<Server>{std::make_shared<Server>(std::move(info), std::move(identity), std::move(settings))}); } catch (const std::exception &ex) { - ctx.raise(js::Error{ex.what()}); + ctx.raise(js::Error(ex.what())); } return 0;
--- a/irccd/js-timer.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/js-timer.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -108,7 +108,7 @@ /* Now store the JavaScript function to call */ ctx.dup(2); - ctx.putGlobal("\xff""\xff""timer-" + std::to_string(reinterpret_cast<intptr_t>(timer.get()))); + ctx.putGlobal("\xff""\xff""timer-" + std::to_string(reinterpret_cast<std::intptr_t>(timer.get()))); return 0; }
--- a/irccd/js-util.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/js-util.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -75,7 +75,7 @@ try { ctx.push(util::format(ctx.get<std::string>(0), ctx.get<util::Substitution>(1))); } catch (const std::exception &ex) { - ctx.raise(js::SyntaxError{ex.what()}); + ctx.raise(js::SyntaxError(ex.what())); } return 1; @@ -98,7 +98,7 @@ char nick[32] = {0}; irc_target_get_nick(target, nick, sizeof (nick) -1); - ctx.push(std::string{nick}); + ctx.push(std::string(nick)); return 1; } @@ -120,7 +120,7 @@ char host[32] = {0}; irc_target_get_host(target, host, sizeof (host) -1); - ctx.push(std::string{host}); + ctx.push(std::string(host)); return 1; }
--- a/irccd/js.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/js.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -63,7 +63,7 @@ { /* 1. Push function wrapper */ duk_push_c_function(ctx, [] (duk_context *ctx) -> duk_ret_t { - Context context{ctx}; + Context context(ctx); duk_push_current_function(ctx); duk_get_prop_string(ctx, -1, "\xff""\xff""js-func");
--- a/irccd/js.h Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/js.h Sun Feb 14 16:15:48 2016 +0100 @@ -345,7 +345,7 @@ * Create default context. */ inline Context() - : m_handle{duk_create_heap_default(), duk_destroy_heap} + : m_handle(duk_create_heap_default(), duk_destroy_heap) { } @@ -355,7 +355,7 @@ * @param ctx the pointer to duk_context */ inline Context(ContextPtr ctx) noexcept - : m_handle{ctx, [] (ContextPtr) {}} + : m_handle(ctx, [] (ContextPtr) {}) { } @@ -1077,9 +1077,9 @@ */ inline StackAssert(Context &ctx, unsigned expected = 0) noexcept #if !defined(NDEBUG) - : m_context{ctx} - , m_expected{expected} - , m_begin{static_cast<unsigned>(m_context.top())} + : m_context(ctx) + , m_expected(expected) + , m_begin(static_cast<unsigned>(m_context.top())) #endif { #if defined(NDEBUG) @@ -1122,8 +1122,8 @@ * @param message the message */ inline Error(std::string name, std::string message) noexcept - : m_name{std::move(name)} - , m_message{std::move(message)} + : m_name(std::move(name)) + , m_message(std::move(message)) { } @@ -1134,8 +1134,8 @@ * @param message the message */ inline Error(std::string message) noexcept - : m_name{"Error"} - , m_message{std::move(message)} + : m_name("Error") + , m_message(std::move(message)) { } @@ -1177,7 +1177,7 @@ * @param message the message */ inline EvalError(std::string message) noexcept - : Error{"EvalError", std::move(message)} + : Error("EvalError", std::move(message)) { } }; @@ -1194,7 +1194,7 @@ * @param message the message */ inline RangeError(std::string message) noexcept - : Error{"RangeError", std::move(message)} + : Error("RangeError", std::move(message)) { } }; @@ -1211,7 +1211,7 @@ * @param message the message */ inline ReferenceError(std::string message) noexcept - : Error{"ReferenceError", std::move(message)} + : Error("ReferenceError", std::move(message)) { } }; @@ -1228,7 +1228,7 @@ * @param message the message */ inline SyntaxError(std::string message) noexcept - : Error{"SyntaxError", std::move(message)} + : Error("SyntaxError", std::move(message)) { } }; @@ -1245,7 +1245,7 @@ * @param message the message */ inline TypeError(std::string message) noexcept - : Error{"TypeError", std::move(message)} + : Error("TypeError", std::move(message)) { } }; @@ -1262,7 +1262,7 @@ * @param message the message */ inline URIError(std::string message) noexcept - : Error{"URIError", std::move(message)} + : Error("URIError", std::move(message)) { } }; @@ -1314,9 +1314,8 @@ */ static inline int optional(Context &ctx, int index, int defaultValue) { - if (!duk_is_number(ctx, index)) { + if (!duk_is_number(ctx, index)) return defaultValue; - } return duk_get_int(ctx, index); } @@ -1388,9 +1387,8 @@ */ static inline bool optional(Context &ctx, int index, bool defaultValue) { - if (!duk_is_boolean(ctx, index)) { + if (!duk_is_boolean(ctx, index)) return defaultValue; - } return duk_get_boolean(ctx, index); } @@ -1462,9 +1460,8 @@ */ static inline double optional(Context &ctx, int index, double defaultValue) { - if (!duk_is_number(ctx, index)) { + if (!duk_is_number(ctx, index)) return defaultValue; - } return duk_get_number(ctx, index); } @@ -1541,9 +1538,8 @@ */ static inline std::string optional(Context &ctx, int index, std::string defaultValue) { - if (!duk_is_string(ctx, index)) { + if (!duk_is_string(ctx, index)) return defaultValue; - } return get(ctx, index); } @@ -1618,9 +1614,8 @@ */ static inline const char *optional(Context &ctx, int index, const char *defaultValue) { - if (!duk_is_string(ctx, index)) { + if (!duk_is_string(ctx, index)) return defaultValue; - } return duk_get_string(ctx, index); } @@ -1691,9 +1686,8 @@ */ static inline T *optional(Context &ctx, int index, RawPointer<T> defaultValue) { - if (!duk_is_pointer(ctx, index)) { + if (!duk_is_pointer(ctx, index)) return defaultValue.object; - } return static_cast<T *>(duk_to_pointer(ctx, index)); } @@ -1760,9 +1754,8 @@ */ static inline void push(Context &ctx, const FunctionMap &map) { - for (const auto &entry : map) { + for (const auto &entry : map) ctx.putProperty(-1, entry.first, entry.second); - } } }; @@ -1978,14 +1971,12 @@ { std::vector<T> result; - if (!duk_is_array(ctx, -1)) { + if (!duk_is_array(ctx, -1)) return result; - } int total = duk_get_length(ctx, index); - for (int i = 0; i < total; ++i) { + for (int i = 0; i < total; ++i) result.push_back(ctx.getProperty<T>(index, i)); - } return result; } @@ -2061,7 +2052,7 @@ */ static void push(Context &ctx, Shared<T> value) { - js::StackAssert sa{ctx, 1}; + js::StackAssert sa(ctx, 1); duk_push_object(ctx); value.object->prototype(ctx); @@ -2149,7 +2140,7 @@ */ static void push(Context &ctx, Pointer<T> value) { - js::StackAssert sa{ctx, 1}; + js::StackAssert sa(ctx, 1); duk_push_object(ctx); apply(ctx, value.object);
--- a/irccd/plugin.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/plugin.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -75,17 +75,17 @@ m_context.putGlobal("\xff""\xff""parent", m_info.parent); } -void Plugin::putPath(const string &varname, const string &append, path::Path type) +void Plugin::putPath(const std::string &varname, const std::string &append, path::Path type) { js::StackAssert sa(m_context); bool found = true; - string foundpath; + std::string foundpath; /* * Use the first existing directory available. */ - for (const string &p : path::list(type)) { + for (const std::string &p : path::list(type)) { foundpath = path::clean(p + append); if (fs::exists(foundpath)) { @@ -250,7 +250,7 @@ m_timers.erase(timer); } -void Plugin::onChannelMode(shared_ptr<Server> server, string origin, string channel, string mode, string arg) +void Plugin::onChannelMode(std::shared_ptr<Server> server, std::string origin, std::string channel, std::string mode, std::string arg) { js::StackAssert sa(m_context); @@ -262,7 +262,7 @@ call("onChannelMode", 5); } -void Plugin::onChannelNotice(shared_ptr<Server> server, string origin, string channel, string notice) +void Plugin::onChannelNotice(std::shared_ptr<Server> server, std::string origin, std::string channel, std::string notice) { js::StackAssert sa(m_context); @@ -273,7 +273,7 @@ call("onChannelNotice", 4); } -void Plugin::onCommand(shared_ptr<Server> server, string origin, string channel, string message) +void Plugin::onCommand(std::shared_ptr<Server> server, std::string origin, std::string channel, std::string message) { js::StackAssert sa(m_context); @@ -284,7 +284,7 @@ call("onCommand", 4); } -void Plugin::onConnect(shared_ptr<Server> server) +void Plugin::onConnect(std::shared_ptr<Server> server) { js::StackAssert sa(m_context); @@ -292,7 +292,7 @@ call("onConnect", 1); } -void Plugin::onInvite(shared_ptr<Server> server, string origin, string channel) +void Plugin::onInvite(std::shared_ptr<Server> server, std::string origin, std::string channel) { js::StackAssert sa(m_context); @@ -302,7 +302,7 @@ call("onInvite", 3); } -void Plugin::onJoin(shared_ptr<Server> server, string origin, string channel) +void Plugin::onJoin(std::shared_ptr<Server> server, std::string origin, std::string channel) { js::StackAssert sa(m_context); @@ -312,7 +312,7 @@ call("onJoin", 3); } -void Plugin::onKick(shared_ptr<Server> server, string origin, string channel, string target, string reason) +void Plugin::onKick(std::shared_ptr<Server> server, std::string origin, std::string channel, std::string target, std::string reason) { js::StackAssert sa(m_context); @@ -331,7 +331,7 @@ call("onLoad", 0); } -void Plugin::onMessage(shared_ptr<Server> server, string origin, string channel, string message) +void Plugin::onMessage(std::shared_ptr<Server> server, std::string origin, std::string channel, std::string message) { js::StackAssert sa(m_context); @@ -342,7 +342,7 @@ call("onMessage", 4); } -void Plugin::onMe(shared_ptr<Server> server, string origin, string channel, string message) +void Plugin::onMe(std::shared_ptr<Server> server, std::string origin, std::string channel, std::string message) { js::StackAssert sa(m_context); @@ -353,7 +353,7 @@ call("onMe", 4); } -void Plugin::onMode(shared_ptr<Server> server, string origin, string mode) +void Plugin::onMode(std::shared_ptr<Server> server, std::string origin, std::string mode) { js::StackAssert sa(m_context); @@ -363,7 +363,7 @@ call("onMode", 3); } -void Plugin::onNames(shared_ptr<Server> server, string channel, vector<string> names) +void Plugin::onNames(std::shared_ptr<Server> server, std::string channel, std::vector<std::string> names) { js::StackAssert sa(m_context); @@ -373,7 +373,7 @@ call("onNames", 3); } -void Plugin::onNick(shared_ptr<Server> server, string oldnick, string newnick) +void Plugin::onNick(std::shared_ptr<Server> server, std::string oldnick, std::string newnick) { js::StackAssert sa(m_context); @@ -383,7 +383,7 @@ call("onNick", 3); } -void Plugin::onNotice(shared_ptr<Server> server, string origin, string notice) +void Plugin::onNotice(std::shared_ptr<Server> server, std::string origin, std::string notice) { js::StackAssert sa(m_context); @@ -393,7 +393,7 @@ call("onNotice", 3); } -void Plugin::onPart(shared_ptr<Server> server, string origin, string channel, string reason) +void Plugin::onPart(std::shared_ptr<Server> server, std::string origin, std::string channel, std::string reason) { js::StackAssert sa(m_context); @@ -404,7 +404,7 @@ call("onPart", 4); } -void Plugin::onQuery(shared_ptr<Server> server, string origin, string message) +void Plugin::onQuery(std::shared_ptr<Server> server, std::string origin, std::string message) { js::StackAssert sa(m_context); @@ -414,7 +414,7 @@ call("onQuery", 3); } -void Plugin::onQueryCommand(shared_ptr<Server> server, string origin, string message) +void Plugin::onQueryCommand(std::shared_ptr<Server> server, std::string origin, std::string message) { js::StackAssert sa(m_context); @@ -431,7 +431,7 @@ call("onReload"); } -void Plugin::onTopic(shared_ptr<Server> server, string origin, string channel, string topic) +void Plugin::onTopic(std::shared_ptr<Server> server, std::string origin, std::string channel, std::string topic) { js::StackAssert sa(m_context); @@ -449,7 +449,7 @@ call("onUnload"); } -void Plugin::onWhois(shared_ptr<Server> server, ServerWhois whois) +void Plugin::onWhois(std::shared_ptr<Server> server, ServerWhois whois) { js::StackAssert sa(m_context);
--- a/irccd/rule.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/rule.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -51,12 +51,12 @@ namespace irccd { -bool Rule::solve(const vector<Rule> &rules, - const string &server, - const string &channel, - const string &origin, - const string &plugin, - const string &event) noexcept +bool Rule::solve(const std::vector<Rule> &rules, + const std::string &server, + const std::string &channel, + const std::string &origin, + const std::string &plugin, + const std::string &event) noexcept { bool result = true; @@ -84,7 +84,7 @@ return result; } -bool Rule::matchMap(const RuleSet &map, const string &value) const noexcept +bool Rule::matchMap(const RuleSet &map, const std::string &value) const noexcept { return value.empty() || map.empty() || map.count(value) == 1; } @@ -102,11 +102,11 @@ throw std::invalid_argument(n + " is not a valid event name"); } -bool Rule::match(const string &server, - const string &channel, - const string &nick, - const string &plugin, - const string &event) const noexcept +bool Rule::match(const std::string &server, + const std::string &channel, + const std::string &nick, + const std::string &plugin, + const std::string &event) const noexcept { return matchMap(m_servers, server) && matchMap(m_channels, channel) &&
--- a/irccd/server-state.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/server-state.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -127,8 +127,8 @@ log::info() << "server " << info.name << ": trying to connect to " << info.host << ", port " << info.port << std::endl; if (!connect(server)) { - log::warning() << "server " << info.name << ": disconnected while connecting: " - << irc_strerror(irc_errno(server.session())) << std::endl; + log::warning() << "server " << info.name << ": disconnected while connecting: "; + log::warning() << irc_strerror(irc_errno(server.session())) << std::endl; server.next(ServerState::Disconnected); } else { m_started = true;
--- a/irccd/timer.cpp Fri Feb 12 21:02:28 2016 +0100 +++ b/irccd/timer.cpp Sun Feb 14 16:15:48 2016 +0100 @@ -37,7 +37,7 @@ continue; /* Wait the timer delay or the interrupt */ - m_condition.wait_for(lock, std::chrono::milliseconds{m_delay}, [&] () { + m_condition.wait_for(lock, std::chrono::milliseconds(m_delay), [&] () { return m_state != Running; });