From 2e9aab5cd0cb9b28a6ec5121e2da50443672d06d Mon Sep 17 00:00:00 2001 From: Kostya Bazhanov Date: Sat, 18 Apr 2015 21:43:37 +0300 Subject: [PATCH 1/3] Remove trailing spaces. --- src/cxxopts.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cxxopts.hpp b/src/cxxopts.hpp index 0d7ae1e..3ff24db 100644 --- a/src/cxxopts.hpp +++ b/src/cxxopts.hpp @@ -54,7 +54,7 @@ namespace cxxopts return icu::UnicodeString::fromUTF8(s); } - class UnicodeStringIterator : public + class UnicodeStringIterator : public std::iterator { public: @@ -244,7 +244,7 @@ namespace cxxopts virtual std::string get_default_value() const = 0; - virtual std::string + virtual std::string get_implicit_value() const = 0; virtual std::shared_ptr @@ -410,7 +410,7 @@ namespace cxxopts //so that we can write --long=yes explicitly value = true; } - + inline void parse_value(const std::string& text, std::string& value) @@ -452,7 +452,7 @@ namespace cxxopts { parse_value(m_implicit_value, *m_store); } - else + else { parse_value(text, *m_store); } @@ -484,14 +484,14 @@ namespace cxxopts virtual std::shared_ptr default_value(const std::string& value){ - m_default = true; + m_default = true; m_default_value = value; return shared_from_this(); } virtual std::shared_ptr implicit_value(const std::string& value){ - m_implicit = true; + m_implicit = true; m_implicit_value = value; return shared_from_this(); } @@ -932,7 +932,7 @@ OptionAdder::operator() const auto& s = result[2]; const auto& l = result[3]; - m_options.add_option(m_group, s.str(), l.str(), desc, value, + m_options.add_option(m_group, s.str(), l.str(), desc, value, std::move(arg_help)); return *this; @@ -969,8 +969,8 @@ Options::checked_parse_arg { throw missing_argument_exception(name); } - } - else + } + else { if (argv[current + 1][0] == '-' && value->value().has_implicit()) { @@ -1243,7 +1243,7 @@ Options::help_one_group(const std::string& g) const } else { - result += toLocalString(std::string(longest + OPTION_DESC_GAP - + result += toLocalString(std::string(longest + OPTION_DESC_GAP - stringLength(fiter->first), ' ')); } From 9c59bb25ff7e65c3ad6b31514dc7954cf5ec4db6 Mon Sep 17 00:00:00 2001 From: Kostya Bazhanov Date: Sat, 18 Apr 2015 21:50:12 +0300 Subject: [PATCH 2/3] Fix Clang -Wsign-conversion and -Wshorten-64-to-32 warnings. --- src/cxxopts.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cxxopts.hpp b/src/cxxopts.hpp index 3ff24db..9b21480 100644 --- a/src/cxxopts.hpp +++ b/src/cxxopts.hpp @@ -196,7 +196,7 @@ namespace cxxopts inline String& - stringAppend(String& s, int n, char c) + stringAppend(String& s, size_t n, char c) { return s.append(n, c); } @@ -846,8 +846,8 @@ namespace cxxopts format_description ( const HelpOptionDetails& o, - int start, - int width + size_t start, + size_t width ) { auto desc = o.desc; @@ -863,7 +863,7 @@ namespace cxxopts auto startLine = current; auto lastSpace = current; - int size = 0; + auto size = size_t{}; while (current != std::end(desc)) { @@ -1228,7 +1228,7 @@ Options::help_one_group(const std::string& g) const longest = std::min(longest, static_cast(OPTION_LONGEST)); //widest allowed description - int allowed = 76 - longest - OPTION_DESC_GAP; + auto allowed = size_t{76} - longest - OPTION_DESC_GAP; auto fiter = format.begin(); for (const auto& o : group->second.options) From 9205d9093beec1e28c8d13cf4c9906b821380447 Mon Sep 17 00:00:00 2001 From: Kostya Bazhanov Date: Thu, 23 Apr 2015 22:05:19 +0300 Subject: [PATCH 3/3] Disable -Wnon-virtual-dtor warning for GCC and Clang. --- src/cxxopts.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cxxopts.hpp b/src/cxxopts.hpp index 9b21480..90dd01f 100644 --- a/src/cxxopts.hpp +++ b/src/cxxopts.hpp @@ -25,6 +25,11 @@ THE SOFTWARE. #ifndef CXX_OPTS_HPP #define CXX_OPTS_HPP +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#endif + #include #include #include @@ -1299,4 +1304,9 @@ Options::group_help(const std::string& group) const } } + +#if defined(__GNU__) +#pragma GCC diagnostic pop +#endif + #endif //CXX_OPTS_HPP