mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 05:02:31 +00:00
cleanup: Changes for c++17
This cleanup adjusts the rTorrent code to comply with c++17 standard. It also simplifies various parts of the code.
This commit is contained in:
+10
-14
@@ -52,17 +52,13 @@ CommandMap commands;
|
||||
XmlRpc xmlrpc;
|
||||
ExecFile execFile;
|
||||
|
||||
struct command_map_is_space : std::unary_function<char, bool> {
|
||||
bool operator () (char c) const {
|
||||
return c == ' ' || c == '\t';
|
||||
}
|
||||
};
|
||||
inline bool command_map_is_space(char c) {
|
||||
return c == ' ' || c == '\t';
|
||||
}
|
||||
|
||||
struct command_map_is_newline : std::unary_function<char, bool> {
|
||||
bool operator () (char c) const {
|
||||
return c == '\n' || c == '\0' || c == ';';
|
||||
}
|
||||
};
|
||||
inline bool command_map_is_newline(char c) {
|
||||
return c == '\n' || c == '\0' || c == ';';
|
||||
}
|
||||
|
||||
// Only escape eol on odd number of escape characters. We know that
|
||||
// there can't be any characters in between, so this should work for
|
||||
@@ -131,7 +127,7 @@ parse_command_name(const char* first, const char* last, char* dest_first, char*
|
||||
// the code below for both cases.
|
||||
parse_command_type
|
||||
parse_command(target_type target, const char* first, const char* last) {
|
||||
first = std::find_if(first, last, std::not1(command_map_is_space()));
|
||||
first = std::find_if(first, last, [&](char c) { return !command_map_is_space(c); });
|
||||
|
||||
if (first == last || *first == '#')
|
||||
return std::make_pair(torrent::Object(), first);
|
||||
@@ -139,7 +135,7 @@ parse_command(target_type target, const char* first, const char* last) {
|
||||
char key[128];
|
||||
|
||||
first = parse_command_name(first, last, key, key + 128);
|
||||
first = std::find_if(first, last, std::not1(command_map_is_space()));
|
||||
first = std::find_if(first, last, [&](char c) { return !command_map_is_space(c); });
|
||||
|
||||
if (first == last || *first != '=')
|
||||
throw torrent::input_error("Could not find '=' in command '" + std::string(key) + "'.");
|
||||
@@ -150,10 +146,10 @@ parse_command(target_type target, const char* first, const char* last) {
|
||||
// Find the last character that is part of this command, skipping
|
||||
// the whitespace at the end. This ensures us that the caller
|
||||
// doesn't need to do this nor check for junk at the end.
|
||||
first = std::find_if(first, last, std::not1(command_map_is_space()));
|
||||
first = std::find_if(first, last, [&](char c) { return !command_map_is_space(c); });
|
||||
|
||||
if (first != last) {
|
||||
if (*first != '\n' && *first != ';' && *first != '\0')
|
||||
if (!command_map_is_newline(*first))
|
||||
throw torrent::input_error("Junk at end of input.");
|
||||
|
||||
first++;
|
||||
|
||||
Reference in New Issue
Block a user