From f003c5585301efc65c1848d71993d8a13a94cdd5 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Thu, 19 Oct 2017 02:20:55 +0100 Subject: [PATCH] Fix -Werror=misleading-indentation errors seen with gcc 6 This looks like an actual bug which has been lurking here since forever, fortunately not exposed since hardly anything uses Option::Optional... libgetopt++/src/OptionSet.cc: In member function 'void OptionSet::doOption(std::__cxx11::string&, const size_type&)': libgetopt++/src/OptionSet.cc:125:25: error: this 'if' clause does not guard... [-Werror=misleading-indentation] if (!isOption(maybepos)) ^~ libgetopt++/src/OptionSet.cc:128:8: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' argv.erase(argv.begin() + 1); ^~~~ libgetopt++/src/OptionSet.cc:159:25: error: this 'if' clause does not guard... [-Werror=misleading-indentation] if (!isOption(maybepos)) ^~ libgetopt++/src/OptionSet.cc:161:8: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' argv.erase(argv.begin() + 1); ^~~~ --- libgetopt++/src/OptionSet.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libgetopt++/src/OptionSet.cc b/libgetopt++/src/OptionSet.cc index f57b89a9..81ffeaeb 100644 --- a/libgetopt++/src/OptionSet.cc +++ b/libgetopt++/src/OptionSet.cc @@ -122,10 +122,11 @@ OptionSet::doOption(string &option, string::size_type const &pos) if (argv.size() > 1) { string::size_type maybepos = argv[1].find_first_not_of("-"); - if (!isOption(maybepos)) + if (!isOption(maybepos)) { /* not an option */ value = argv[1]; argv.erase(argv.begin() + 1); + } } } else { /* value if present is in this argv */ @@ -156,9 +157,10 @@ OptionSet::doOption(string &option, string::size_type const &pos) if (argv.size() > 1) { string::size_type maybepos = argv[1].find_first_not_of("-"); - if (!isOption(maybepos)) + if (!isOption(maybepos)) { value = argv[1]; argv.erase(argv.begin() + 1); + } } } } -- 2.43.5