From bce268dea4566b635988089cc612fcf94653096e Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 12 Apr 2015 16:15:57 +0200 Subject: [PATCH 1/6] change version to 0.6.4_pre --- NEWS | 2 ++ configure.ac | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 02bcd9c8..171a21bf 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +ncmpcpp-0.6.4 (????-??-??) + ncmpcpp-0.6.3 (2015-03-02) * Fix floating point exception when adding a specific number of random items. diff --git a/configure.ac b/configure.ac index 2fb38838..e2c1b34b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_INIT(configure.ac) AC_CONFIG_HEADERS(config.h) -AM_INIT_AUTOMAKE(ncmpcpp, 0.6.3) +AM_INIT_AUTOMAKE(ncmpcpp, 0.6.4_pre) AC_PREREQ(2.59) From b63d646e48912b4f1deba517ac271ac9ed748409 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 12 Apr 2015 16:20:57 +0200 Subject: [PATCH 2/6] selected item adder: fix pop-up title when adding items to the current playlist --- NEWS | 2 ++ src/sel_items_adder.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 171a21bf..97decf61 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ ncmpcpp-0.6.4 (????-??-??) +* Fix title of a pop-up which shows during adding selected items to the current playlist. + ncmpcpp-0.6.3 (2015-03-02) * Fix floating point exception when adding a specific number of random items. diff --git a/src/sel_items_adder.cpp b/src/sel_items_adder.cpp index 68fad684..14dc6d59 100644 --- a/src/sel_items_adder.cpp +++ b/src/sel_items_adder.cpp @@ -69,7 +69,7 @@ SelectedItemsAdder::SelectedItemsAdder() MainStartY+(MainHeight-m_position_selector_height)/2, m_position_selector_width, m_position_selector_height, - "Scroll?", + "Where?", Config.main_color, Config.window_border ); From bb4c0a9d4c5fa21e7d8cf767556b9bb28192e132 Mon Sep 17 00:00:00 2001 From: jgr Date: Tue, 24 Mar 2015 02:39:59 +1000 Subject: [PATCH 3/6] tag editor: fix leading separator issue (#32) --- NEWS | 1 + src/tag_editor.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 97decf61..4433a568 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ncmpcpp-0.6.4 (????-??-??) * Fix title of a pop-up which shows during adding selected items to the current playlist. +* Correctly deal with leading separator while parsing filenames in tag editor. ncmpcpp-0.6.3 (2015-03-02) diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index 0f018233..2532d647 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -1148,7 +1148,12 @@ std::string ParseFilename(MPD::MutableSong &s, std::string mask, bool preview) std::vector< std::pair > tags; std::string file = s.getName().substr(0, s.getName().rfind(".")); - for (size_t i = mask.find("%"); i != std::string::npos; i = mask.find("%")) + size_t i = mask.find("%"); + + if (!mask.substr(0, i).empty()) + file = file.substr(i); + + for (; i != std::string::npos; i = mask.find("%")) { tags.push_back(std::make_pair(mask.at(i+1), "")); mask = mask.substr(i+2); @@ -1156,7 +1161,7 @@ std::string ParseFilename(MPD::MutableSong &s, std::string mask, bool preview) if (!mask.empty()) separators.push_back(mask.substr(0, i)); } - size_t i = 0; + i = 0; for (auto it = separators.begin(); it != separators.end(); ++it, ++i) { size_t j = file.find(*it); From 5a3a2fbbf1eccf9dcd10b3c207be8921ea4330f8 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 2 May 2015 20:43:19 +0200 Subject: [PATCH 4/6] set SIGWINCH handler before initializing ncurses to avoid races --- NEWS | 1 + src/ncmpcpp.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 4433a568..79d648de 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ ncmpcpp-0.6.4 (????-??-??) * Fix title of a pop-up which shows during adding selected items to the current playlist. * Correctly deal with leading separator while parsing filenames in tag editor. +* Fix initial incorrect window size that was occuring in some cases. ncmpcpp-0.6.3 (2015-03-02) diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index db7d7007..c53a0fb9 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -111,6 +111,13 @@ int main(int argc, char **argv) cerr_buffer = std::cerr.rdbuf(); std::cerr.rdbuf(errorlog.rdbuf()); +# ifndef WIN32 + signal(SIGPIPE, sighandler); + signal(SIGWINCH, sighandler); + // ignore Ctrl-C + sigignore(SIGINT); +# endif // !WIN32 + NC::initScreen("ncmpcpp ver. " VERSION, Config.colors_enabled); Actions::OriginalStatusbarVisibility = Config.statusbar_visibility; @@ -146,13 +153,6 @@ int main(int argc, char **argv) if (Config.mouse_support) mousemask(ALL_MOUSE_EVENTS, 0); -# ifndef WIN32 - signal(SIGPIPE, sighandler); - signal(SIGWINCH, sighandler); - // ignore Ctrl-C - sigignore(SIGINT); -# endif // !WIN32 - while (!Actions::ExitMainLoop) { try From 77c702100f8ab296a44966f756f98b37a6dc4dd3 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 2 May 2015 20:50:12 +0200 Subject: [PATCH 5/6] change version to 0.6.4 --- NEWS | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 79d648de..d33225d0 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -ncmpcpp-0.6.4 (????-??-??) +ncmpcpp-0.6.4 (2015-05-02) * Fix title of a pop-up which shows during adding selected items to the current playlist. * Correctly deal with leading separator while parsing filenames in tag editor. diff --git a/configure.ac b/configure.ac index e2c1b34b..697322e3 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_INIT(configure.ac) AC_CONFIG_HEADERS(config.h) -AM_INIT_AUTOMAKE(ncmpcpp, 0.6.4_pre) +AM_INIT_AUTOMAKE(ncmpcpp, 0.6.4) AC_PREREQ(2.59) From a40508179a9ef4601415c167abe04432038e82ce Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 2 May 2015 21:16:11 +0200 Subject: [PATCH 6/6] configuration: add 'ignore-config-errors' switch --- NEWS | 1 + src/configuration.cpp | 3 ++- src/settings.cpp | 4 ++-- src/settings.h | 2 +- src/utility/option_parser.cpp | 11 +++++++---- src/utility/option_parser.h | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index d33225d0..e803dc97 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ ncmpcpp-0.6.4 (2015-05-02) * Fix title of a pop-up which shows during adding selected items to the current playlist. * Correctly deal with leading separator while parsing filenames in tag editor. * Fix initial incorrect window size that was occuring in some cases. +* Unknown and invalid configuration options can now be ignored using command line option 'ignore-config-errors'. ncmpcpp-0.6.3 (2015-03-02) diff --git a/src/configuration.cpp b/src/configuration.cpp index d44ba4fa..05cb338e 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -54,6 +54,7 @@ bool configure(int argc, char **argv) ("host,h", po::value()->default_value("localhost"), "connect to server at host") ("port,p", po::value()->default_value(6600), "connect to server at port") ("config,c", po::value(&config_path)->default_value("~/.ncmpcpp/config"), "specify configuration file") + ("ignore-config-errors", po::value()->default_value(false), "ignore unknown and invalid options in configuration file") ("bindings,b", po::value(&bindings_path)->default_value("~/.ncmpcpp/bindings"), "specify bindings file") ("screen,s", po::value(), "specify initial screen") ("help,?", "show help message") @@ -130,7 +131,7 @@ bool configure(int argc, char **argv) // read configuration expand_home(config_path); - if (Config.read(config_path) == false) + if (Config.read(config_path, vm["ignore-config-errors"].as()) == false) exit(1); // if bindings file was not specified, use the one from main directory. diff --git a/src/settings.cpp b/src/settings.cpp index aa38d70d..b044f558 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -179,7 +179,7 @@ option_parser::worker buffer(NC::Buffer &arg, ValueT &&value, TransformT &&map) } -bool Configuration::read(const std::string &config_path) +bool Configuration::read(const std::string &config_path, bool ignore_errors) { std::string mpd_host; unsigned mpd_port; @@ -640,5 +640,5 @@ bool Configuration::read(const std::string &config_path) )); std::ifstream f(config_path); - return p.run(f); + return p.run(f, ignore_errors); } diff --git a/src/settings.h b/src/settings.h index 01959da8..52523ee4 100644 --- a/src/settings.h +++ b/src/settings.h @@ -51,7 +51,7 @@ struct Configuration : playlist_disable_highlight_delay(0), visualizer_sync_interval(0) { } - bool read(const std::string &config_path); + bool read(const std::string &config_path, bool ignore_errors); std::string ncmpcpp_directory; std::string lyrics_directory; diff --git a/src/utility/option_parser.cpp b/src/utility/option_parser.cpp index 21f4cbd6..029c23c6 100644 --- a/src/utility/option_parser.cpp +++ b/src/utility/option_parser.cpp @@ -35,7 +35,7 @@ #include "utility/option_parser.h" -bool option_parser::run(std::istream &is) +bool option_parser::run(std::istream &is, bool ignore_errors) { // quoted value. leftmost and rightmost quotation marks are the delimiters. boost::regex quoted("(\\w+)\\h*=\\h*\"(.*)\"[^\"]*"); @@ -56,13 +56,15 @@ bool option_parser::run(std::istream &is) it->second.parse(match[2]); } catch (std::exception &e) { std::cerr << "Error while processing option \"" << option << "\": " << e.what() << "\n"; - return false; + if (!ignore_errors) + return false; } } else { std::cerr << "Unknown option: " << option << "\n"; - return false; + if (!ignore_errors) + return false; } } } @@ -74,7 +76,8 @@ bool option_parser::run(std::istream &is) p.second.run_default(); } catch (std::exception &e) { std::cerr << "Error while finalizing option \"" << p.first << "\": " << e.what() << "\n"; - return false; + if (ignore_errors) + return false; } } } diff --git a/src/utility/option_parser.h b/src/utility/option_parser.h index 6b366bd9..7a326d62 100644 --- a/src/utility/option_parser.h +++ b/src/utility/option_parser.h @@ -129,7 +129,7 @@ struct option_parser m_parsers[option] = std::forward(w); } - bool run(std::istream &is); + bool run(std::istream &is, bool ignore_errors); private: std::unordered_map m_parsers;