diff options
author | 2020-08-03 16:10:32 +0200 | |
---|---|---|
committer | 2020-08-04 10:18:38 +0200 | |
commit | fde721b7c79833f453f978c937ae276f88a8ab80 (patch) | |
tree | bd1df0d7a358fbdcc58cb5de1984c4519ed39a2e | |
parent | 259afa5353de2d799829ff85dde7194a6e119ddc (diff) | |
download | newsboat-fde721b7c79833f453f978c937ae276f88a8ab80.tar.gz newsboat-fde721b7c79833f453f978c937ae276f88a8ab80.tar.zst newsboat-fde721b7c79833f453f978c937ae276f88a8ab80.zip |
Rename ConfigParser::parse() -> parse_file()
-rw-r--r-- | include/configparser.h | 2 | ||||
-rw-r--r-- | src/configparser.cpp | 10 | ||||
-rw-r--r-- | src/controller.cpp | 6 | ||||
-rw-r--r-- | src/pbcontroller.cpp | 4 | ||||
-rw-r--r-- | test/colormanager.cpp | 2 | ||||
-rw-r--r-- | test/configcontainer.cpp | 4 | ||||
-rw-r--r-- | test/configparser.cpp | 18 | ||||
-rw-r--r-- | test/remoteapi.cpp | 2 |
8 files changed, 24 insertions, 24 deletions
diff --git a/include/configparser.h b/include/configparser.h index 69775a92..8fb9f05b 100644 --- a/include/configparser.h +++ b/include/configparser.h @@ -28,7 +28,7 @@ public: { /* nothing because ConfigParser itself only handles include */ } - bool parse(const std::string& filename); + bool parse_file(const std::string& filename); static std::string evaluate_backticks(std::string token); private: diff --git a/src/configparser.cpp b/src/configparser.cpp index 3c0a9a86..be29d261 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -39,7 +39,7 @@ void ConfigParser::handle_action(const std::string& action, std::string tilde_expanded = utils::resolve_tilde(params[0]); std::string current_fpath = included_files.back(); - if (!this->parse(utils::resolve_relative(current_fpath, tilde_expanded))) + if (!this->parse_file(utils::resolve_relative(current_fpath, tilde_expanded))) throw ConfigHandlerException( ActionHandlerStatus::FILENOTFOUND); } else @@ -47,7 +47,7 @@ void ConfigParser::handle_action(const std::string& action, ActionHandlerStatus::INVALID_COMMAND); } -bool ConfigParser::parse(const std::string& tmp_filename) +bool ConfigParser::parse_file(const std::string& tmp_filename) { /* * this function parses a config file. @@ -73,7 +73,7 @@ bool ConfigParser::parse(const std::string& tmp_filename) if (std::find(included_files.begin(), included_files.end(), filename) != included_files.end()) { LOG(Level::WARN, - "ConfigParser::parse: file %s has already been " + "ConfigParser::parse_file: file %s has already been " "included", filename); return true; @@ -85,7 +85,7 @@ bool ConfigParser::parse(const std::string& tmp_filename) std::string line; if (!f.is_open()) { LOG(Level::WARN, - "ConfigParser::parse: file %s couldn't be opened", + "ConfigParser::parse_file: file %s couldn't be opened", filename); return false; } @@ -93,7 +93,7 @@ bool ConfigParser::parse(const std::string& tmp_filename) while (f.is_open() && !f.eof()) { getline(f, line); ++linecounter; - LOG(Level::DEBUG, "ConfigParser::parse: tokenizing %s", line); + LOG(Level::DEBUG, "ConfigParser::parse_file: tokenizing %s", line); auto stripped = utils::strip_comments(line); auto evaluated = evaluate_backticks(std::move(stripped)); diff --git a/src/controller.cpp b/src/controller.cpp index e30894aa..59078ed9 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -186,8 +186,8 @@ int Controller::run(const CliArgsParser& args) cfgparser.register_handler("highlight-article", rxman); try { - cfgparser.parse("/etc/" PROGRAM_NAME "/config"); - cfgparser.parse(configpaths.config_file()); + cfgparser.parse_file("/etc/" PROGRAM_NAME "/config"); + cfgparser.parse_file(configpaths.config_file()); } catch (const ConfigException& ex) { LOG(Level::ERROR, "an exception occurred while parsing the configuration " @@ -874,7 +874,7 @@ void Controller::update_config() void Controller::load_configfile(const std::string& filename) { - if (cfgparser.parse(filename)) { + if (cfgparser.parse_file(filename)) { update_config(); } else { v->show_error(strprintf::fmt( diff --git a/src/pbcontroller.cpp b/src/pbcontroller.cpp index 75e5009a..5890b9a1 100644 --- a/src/pbcontroller.cpp +++ b/src/pbcontroller.cpp @@ -279,8 +279,8 @@ int PbController::initialize(int argc, char* argv[]) cfgparser.register_handler("reset-unread-on-update", null_cah); try { - cfgparser.parse("/etc/newsboat/config"); - cfgparser.parse(config_file); + cfgparser.parse_file("/etc/newsboat/config"); + cfgparser.parse_file(config_file); } catch (const ConfigException& ex) { std::cout << ex.what() << std::endl; return EXIT_FAILURE; diff --git a/test/colormanager.cpp b/test/colormanager.cpp index 6865a9d2..baab8cf3 100644 --- a/test/colormanager.cpp +++ b/test/colormanager.cpp @@ -113,7 +113,7 @@ TEST_CASE("register_commands() registers ColorManager with ConfigParser", REQUIRE_NOTHROW(clr.register_commands(cfg)); REQUIRE_FALSE(clr.colors_loaded()); - cfg.parse("data/config-with-colors"); + cfg.parse_file("data/config-with-colors"); REQUIRE(clr.colors_loaded()); } diff --git a/test/configcontainer.cpp b/test/configcontainer.cpp index 3f80a8d7..6fcbb39b 100644 --- a/test/configcontainer.cpp +++ b/test/configcontainer.cpp @@ -17,7 +17,7 @@ TEST_CASE("Parses test config without exceptions", "[ConfigContainer]") KeyMap k(KM_NEWSBOAT); cfgparser.register_handler("macro", k); - REQUIRE_NOTHROW(cfgparser.parse("data/test-config.txt")); + REQUIRE_NOTHROW(cfgparser.parse_file("data/test-config.txt")); SECTION("bool value") { REQUIRE(cfg.get_configvalue("show-read-feeds") == "no"); @@ -48,7 +48,7 @@ TEST_CASE( ConfigParser cfgparser; cfg.register_commands(cfgparser); - REQUIRE_NOTHROW(cfgparser.parse( + REQUIRE_NOTHROW(cfgparser.parse_file( "data/test-config-without-newline-at-the-end.txt")); SECTION("first line") { diff --git a/test/configparser.cpp b/test/configparser.cpp index a0fd4973..24de5db9 100644 --- a/test/configparser.cpp +++ b/test/configparser.cpp @@ -54,7 +54,7 @@ TEST_CASE("evaluate_backticks replaces command in backticks with its output", ConfigParser cfgparser; KeyMap keys(KM_NEWSBOAT); cfgparser.register_handler("bind-key", keys); - REQUIRE_NOTHROW(cfgparser.parse("data/config-space-backticks")); + REQUIRE_NOTHROW(cfgparser.parse_file("data/config-space-backticks")); REQUIRE(keys.get_operation("s", "feedlist") == OP_SORT); } @@ -92,7 +92,7 @@ TEST_CASE("\"unbind-key -a\" removes all key bindings", "[ConfigParser]") SECTION("In all contexts by default") { KeyMap keys(KM_NEWSBOAT); cfgparser.register_handler("unbind-key", keys); - cfgparser.parse("data/config-unbind-all"); + cfgparser.parse_file("data/config-unbind-all"); for (int i = OP_QUIT; i < OP_NB_MAX; ++i) { REQUIRE(keys.get_keys(static_cast<Operation>(i), @@ -105,7 +105,7 @@ TEST_CASE("\"unbind-key -a\" removes all key bindings", "[ConfigParser]") SECTION("For a specific context") { KeyMap keys(KM_NEWSBOAT); cfgparser.register_handler("unbind-key", keys); - cfgparser.parse("data/config-unbind-all-context"); + cfgparser.parse_file("data/config-unbind-all-context"); INFO("it doesn't affect the help dialog"); KeyMap default_keys(KM_NEWSBOAT); @@ -126,19 +126,19 @@ TEST_CASE("include directive includes other config files", "[ConfigParser]") // TODO: error messages should be more descriptive than "file couldn't be opened" ConfigParser cfgparser; SECTION("Errors on not found file") { - REQUIRE_THROWS(cfgparser.parse("data/config-missing-include")); + REQUIRE_THROWS(cfgparser.parse_file("data/config-missing-include")); } SECTION("Terminates on recursive include") { - REQUIRE_THROWS(cfgparser.parse("data/config-recursive-include")); + REQUIRE_THROWS(cfgparser.parse_file("data/config-recursive-include")); } SECTION("Successfully includes existing file") { - REQUIRE_NOTHROW(cfgparser.parse("data/config-absolute-include")); + REQUIRE_NOTHROW(cfgparser.parse_file("data/config-absolute-include")); } SECTION("Success on relative includes") { - REQUIRE_NOTHROW(cfgparser.parse("data/config-relative-include")); + REQUIRE_NOTHROW(cfgparser.parse_file("data/config-relative-include")); } SECTION("Diamond of death includes pass") { - REQUIRE_NOTHROW(cfgparser.parse("data/diamond-of-death/A")); + REQUIRE_NOTHROW(cfgparser.parse_file("data/diamond-of-death/A")); } SECTION("File including itself only gets evaluated once") { TestHelpers::TempFile testfile; @@ -147,7 +147,7 @@ TEST_CASE("include directive includes other config files", "[ConfigParser]") // recursive includes don't fail REQUIRE_NOTHROW( - cfgparser.parse("data/recursive-include-side-effect")); + cfgparser.parse_file("data/recursive-include-side-effect")); // I think it will never get below here and fail? If it recurses, the above fails int line_count = 0; diff --git a/test/remoteapi.cpp b/test/remoteapi.cpp index ef510e7b..557952ab 100644 --- a/test/remoteapi.cpp +++ b/test/remoteapi.cpp @@ -58,7 +58,7 @@ TEST_CASE("get_credentials() returns the users name and password", ConfigContainer cfg; ConfigParser cfgparser; cfg.register_commands(cfgparser); - cfgparser.parse("data/test-config-credentials.txt"); + cfgparser.parse_file("data/test-config-credentials.txt"); std::unique_ptr<test_api> api(new test_api(&cfg)); REQUIRE(api->get_user("ttrss", "") == "ttrss-user"); REQUIRE(api->get_pass("ttrss", "") == "my-birthday"); |