configuration: trim MPD_PORT value before passing it to lexical_cast
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -178,8 +179,9 @@ bool configure(int argc, char **argv)
|
|||||||
Mpd.SetHostname(env_host);
|
Mpd.SetHostname(env_host);
|
||||||
if (env_port != nullptr)
|
if (env_port != nullptr)
|
||||||
{
|
{
|
||||||
|
auto trimmed_env_port = boost::trim_copy<std::string>(env_port);
|
||||||
try {
|
try {
|
||||||
Mpd.SetPort(boost::lexical_cast<int>(env_port));
|
Mpd.SetPort(boost::lexical_cast<int>(trimmed_env_port));
|
||||||
} catch (boost::bad_lexical_cast &) {
|
} catch (boost::bad_lexical_cast &) {
|
||||||
throw std::runtime_error("MPD_PORT environment variable ("
|
throw std::runtime_error("MPD_PORT environment variable ("
|
||||||
+ std::string(env_port)
|
+ std::string(env_port)
|
||||||
|
|||||||
Reference in New Issue
Block a user