Merge branch '0.6.x'

This commit is contained in:
Andrzej Rybczak
2015-05-02 21:31:26 +02:00
9 changed files with 39 additions and 22 deletions

7
NEWS
View File

@@ -20,6 +20,13 @@ ncmpcpp-0.7 (????-??-??)
* BOOST_LIB_SUFFIX configure variable is now empty by default. * BOOST_LIB_SUFFIX configure variable is now empty by default.
* Shuffle function now shuffles only selected range if selection in playlist is active. * Shuffle function now shuffles only selected range if selection in playlist is active.
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) ncmpcpp-0.6.3 (2015-03-02)
* Fix floating point exception when adding a specific number of random items. * Fix floating point exception when adding a specific number of random items.

View File

@@ -78,6 +78,7 @@ bool configure(int argc, char **argv)
("host,h", po::value<std::string>()->default_value("localhost"), "connect to server at host") ("host,h", po::value<std::string>()->default_value("localhost"), "connect to server at host")
("port,p", po::value<int>()->default_value(6600), "connect to server at port") ("port,p", po::value<int>()->default_value(6600), "connect to server at port")
("config,c", po::value<std::vector<std::string>>(&config_paths)->default_value(default_config_paths, join<std::string>(default_config_paths, " AND ")), "specify configuration file(s)") ("config,c", po::value<std::vector<std::string>>(&config_paths)->default_value(default_config_paths, join<std::string>(default_config_paths, " AND ")), "specify configuration file(s)")
("ignore-config-errors", po::value<bool>()->default_value(false), "ignore unknown and invalid options in configuration files")
("bindings,b", po::value<std::string>(&bindings_path)->default_value("~/.ncmpcpp/bindings"), "specify bindings file") ("bindings,b", po::value<std::string>(&bindings_path)->default_value("~/.ncmpcpp/bindings"), "specify bindings file")
("screen,s", po::value<std::string>(), "specify initial screen") ("screen,s", po::value<std::string>(), "specify initial screen")
("slave-screen,S", po::value<std::string>(), "specify initial slave screen") ("slave-screen,S", po::value<std::string>(), "specify initial slave screen")
@@ -150,7 +151,7 @@ bool configure(int argc, char **argv)
// read configuration // read configuration
std::for_each(config_paths.begin(), config_paths.end(), expand_home); std::for_each(config_paths.begin(), config_paths.end(), expand_home);
if (Config.read(config_paths) == false) if (Config.read(config_paths, vm["ignore-config-errors"].as<bool>()) == false)
exit(1); exit(1);
// if bindings file was not specified, use the one from main directory. // if bindings file was not specified, use the one from main directory.

View File

@@ -103,6 +103,13 @@ int main(int argc, char **argv)
cerr_buffer = std::cerr.rdbuf(); cerr_buffer = std::cerr.rdbuf();
std::cerr.rdbuf(errorlog.rdbuf()); std::cerr.rdbuf(errorlog.rdbuf());
# ifndef WIN32
signal(SIGPIPE, sighandler);
signal(SIGWINCH, sighandler);
// ignore Ctrl-C
sigignore(SIGINT);
# endif // !WIN32
NC::initScreen(Config.colors_enabled); NC::initScreen(Config.colors_enabled);
Actions::OriginalStatusbarVisibility = Config.statusbar_visibility; Actions::OriginalStatusbarVisibility = Config.statusbar_visibility;
@@ -151,12 +158,6 @@ int main(int argc, char **argv)
if (Config.mouse_support) if (Config.mouse_support)
mousemask(ALL_MOUSE_EVENTS, 0); mousemask(ALL_MOUSE_EVENTS, 0);
signal(SIGWINCH, sighandler);
// we get it after connection with mpd is broken.
// just ignore it and wait for the connection to
// be reestablished.
sigignore(SIGPIPE);
while (!Actions::ExitMainLoop) while (!Actions::ExitMainLoop)
{ {
try try

View File

@@ -70,7 +70,7 @@ SelectedItemsAdder::SelectedItemsAdder()
MainStartY+(MainHeight-m_position_selector_height)/2, MainStartY+(MainHeight-m_position_selector_height)/2,
m_position_selector_width, m_position_selector_width,
m_position_selector_height, m_position_selector_height,
"Scroll?", "Where?",
Config.main_color, Config.main_color,
Config.window_border Config.window_border
); );

View File

@@ -190,7 +190,7 @@ option_parser::worker border(NC::Border &arg, NC::Border value)
} }
bool Configuration::read(const std::vector<std::string> &config_paths) bool Configuration::read(const std::vector<std::string> &config_paths, bool ignore_errors)
{ {
std::string mpd_host; std::string mpd_host;
unsigned mpd_port; unsigned mpd_port;
@@ -678,13 +678,13 @@ bool Configuration::read(const std::vector<std::string> &config_paths)
return std::all_of( return std::all_of(
config_paths.begin(), config_paths.begin(),
config_paths.end(), config_paths.end(),
[&p](const std::string &config_path) { [&](const std::string &config_path) {
std::ifstream f(config_path); std::ifstream f(config_path);
if (f.is_open()) if (f.is_open())
std::clog << "Reading configuration from " << config_path << "...\n"; std::clog << "Reading configuration from " << config_path << "...\n";
return p.run(f); return p.run(f, ignore_errors);
} }
) && p.initialize_undefined(); ) && p.initialize_undefined(ignore_errors);
} }
/* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab : */ /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab : */

View File

@@ -53,7 +53,7 @@ struct Configuration
: playlist_disable_highlight_delay(0), visualizer_sync_interval(0) : playlist_disable_highlight_delay(0), visualizer_sync_interval(0)
{ } { }
bool read(const std::vector<std::string> &config_paths); bool read(const std::vector<std::string> &config_paths, bool ignore_errors);
std::string ncmpcpp_directory; std::string ncmpcpp_directory;
std::string lyrics_directory; std::string lyrics_directory;

View File

@@ -1066,7 +1066,12 @@ std::string ParseFilename(MPD::MutableSong &s, std::string mask, bool preview)
std::vector< std::pair<char, std::string> > tags; std::vector< std::pair<char, std::string> > tags;
std::string file = s.getName().substr(0, s.getName().rfind(".")); 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), "")); tags.push_back(std::make_pair(mask.at(i+1), ""));
mask = mask.substr(i+2); mask = mask.substr(i+2);
@@ -1074,7 +1079,7 @@ std::string ParseFilename(MPD::MutableSong &s, std::string mask, bool preview)
if (!mask.empty()) if (!mask.empty())
separators.push_back(mask.substr(0, i)); separators.push_back(mask.substr(0, i));
} }
size_t i = 0; i = 0;
for (auto it = separators.begin(); it != separators.end(); ++it, ++i) for (auto it = separators.begin(); it != separators.end(); ++it, ++i)
{ {
size_t j = file.find(*it); size_t j = file.find(*it);

View File

@@ -35,7 +35,7 @@
#include "utility/option_parser.h" #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. // quoted value. leftmost and rightmost quotation marks are the delimiters.
boost::regex quoted("(\\w+)\\h*=\\h*\"(.*)\"[^\"]*"); boost::regex quoted("(\\w+)\\h*=\\h*\"(.*)\"[^\"]*");
@@ -56,20 +56,22 @@ bool option_parser::run(std::istream &is)
it->second.parse(match[2]); it->second.parse(match[2]);
} catch (std::exception &e) { } catch (std::exception &e) {
std::cerr << "Error while processing option \"" << option << "\": " << e.what() << "\n"; std::cerr << "Error while processing option \"" << option << "\": " << e.what() << "\n";
return false; if (!ignore_errors)
return false;
} }
} }
else else
{ {
std::cerr << "Unknown option: " << option << "\n"; std::cerr << "Unknown option: " << option << "\n";
return false; if (!ignore_errors)
return false;
} }
} }
} }
return true; return true;
} }
bool option_parser::initialize_undefined() bool option_parser::initialize_undefined(bool ignore_errors)
{ {
for (auto &p : m_parsers) for (auto &p : m_parsers)
{ {
@@ -79,7 +81,8 @@ bool option_parser::initialize_undefined()
p.second.run_default(); p.second.run_default();
} catch (std::exception &e) { } catch (std::exception &e) {
std::cerr << "Error while initializing option \"" << p.first << "\": " << e.what() << "\n"; std::cerr << "Error while initializing option \"" << p.first << "\": " << e.what() << "\n";
return false; if (ignore_errors)
return false;
} }
} }
} }

View File

@@ -139,8 +139,8 @@ struct option_parser
m_parsers[option] = std::forward<WorkerT>(w); m_parsers[option] = std::forward<WorkerT>(w);
} }
bool run(std::istream &is); bool run(std::istream &is, bool ignore_errors);
bool initialize_undefined(); bool initialize_undefined(bool ignore_errors);
private: private:
std::unordered_map<std::string, worker> m_parsers; std::unordered_map<std::string, worker> m_parsers;