GCC 4.8 fixes

This commit is contained in:
Jarryd Beck 2022-07-25 07:21:22 +10:00
parent a6bfe2d457
commit 01798ee7a0

View File

@ -337,6 +337,9 @@ const std::string RQUOTE("");
// destructor This will be ignored under other compilers like LLVM clang. // destructor This will be ignored under other compilers like LLVM clang.
CXXOPTS_DIAGNOSTIC_PUSH CXXOPTS_DIAGNOSTIC_PUSH
CXXOPTS_IGNORE_WARNING("-Wnon-virtual-dtor") CXXOPTS_IGNORE_WARNING("-Wnon-virtual-dtor")
// some older versions of GCC warn under this warning
CXXOPTS_IGNORE_WARNING("-Weffc++")
class Value : public std::enable_shared_from_this<Value> class Value : public std::enable_shared_from_this<Value>
{ {
public: public:
@ -647,6 +650,11 @@ inline OptionNames split_option_names(const std::string &text)
std::string::size_type token_start_pos = 0; std::string::size_type token_start_pos = 0;
auto length = text.length(); auto length = text.length();
if (length == 0)
{
throw_or_mimic<exceptions::invalid_option_format>(text);
}
while (token_start_pos < length) { while (token_start_pos < length) {
const auto &npos = std::string::npos; const auto &npos = std::string::npos;
auto next_non_space_pos = text.find_first_not_of(' ', token_start_pos); auto next_non_space_pos = text.find_first_not_of(' ', token_start_pos);
@ -1766,8 +1774,8 @@ class Options
{ {
public: public:
explicit Options(std::string program, std::string help_string = "") explicit Options(std::string program_name, std::string help_string = "")
: m_program(std::move(program)) : m_program(std::move(program_name))
, m_help_string(toLocalString(std::move(help_string))) , m_help_string(toLocalString(std::move(help_string)))
, m_custom_help("[OPTION...]") , m_custom_help("[OPTION...]")
, m_positional_help("positional parameters") , m_positional_help("positional parameters")