diff options
Diffstat (limited to 'absl/flags/parse.cc')
-rw-r--r-- | absl/flags/parse.cc | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/absl/flags/parse.cc b/absl/flags/parse.cc index fd80a0c8..812e4981 100644 --- a/absl/flags/parse.cc +++ b/absl/flags/parse.cc @@ -17,43 +17,58 @@ #include <stdlib.h> +#include <algorithm> #include <fstream> #include <iostream> +#include <iterator> +#include <string> #include <tuple> +#include <utility> +#include <vector> #ifdef _WIN32 #include <windows.h> #endif +#include "absl/base/attributes.h" +#include "absl/base/config.h" +#include "absl/base/const_init.h" +#include "absl/base/thread_annotations.h" +#include "absl/flags/config.h" #include "absl/flags/flag.h" +#include "absl/flags/internal/commandlineflag.h" +#include "absl/flags/internal/flag.h" +#include "absl/flags/internal/parse.h" #include "absl/flags/internal/program_name.h" #include "absl/flags/internal/registry.h" #include "absl/flags/internal/usage.h" #include "absl/flags/usage.h" #include "absl/flags/usage_config.h" +#include "absl/strings/ascii.h" #include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" #include "absl/strings/strip.h" #include "absl/synchronization/mutex.h" // -------------------------------------------------------------------- namespace absl { -inline namespace lts_2019_08_08 { +ABSL_NAMESPACE_BEGIN namespace flags_internal { namespace { ABSL_CONST_INIT absl::Mutex processing_checks_guard(absl::kConstInit); ABSL_CONST_INIT bool flagfile_needs_processing - GUARDED_BY(processing_checks_guard) = false; + ABSL_GUARDED_BY(processing_checks_guard) = false; ABSL_CONST_INIT bool fromenv_needs_processing - GUARDED_BY(processing_checks_guard) = false; + ABSL_GUARDED_BY(processing_checks_guard) = false; ABSL_CONST_INIT bool tryfromenv_needs_processing - GUARDED_BY(processing_checks_guard) = false; + ABSL_GUARDED_BY(processing_checks_guard) = false; } // namespace } // namespace flags_internal -} // inline namespace lts_2019_08_08 +ABSL_NAMESPACE_END } // namespace absl ABSL_FLAG(std::vector<std::string>, flagfile, {}, @@ -111,7 +126,7 @@ ABSL_FLAG(std::vector<std::string>, undefok, {}, "with that name"); namespace absl { -inline namespace lts_2019_08_08 { +ABSL_NAMESPACE_BEGIN namespace flags_internal { namespace { @@ -280,9 +295,7 @@ void CheckDefaultValuesParsingRoundtrip() { #define IGNORE_TYPE(T) \ if (flag->IsOfType<T>()) return; - ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(IGNORE_TYPE) - IGNORE_TYPE(std::string) - IGNORE_TYPE(std::vector<std::string>) + ABSL_FLAGS_INTERNAL_BUILTIN_TYPES(IGNORE_TYPE) #undef IGNORE_TYPE flag->CheckDefaultValueParsingRoundtrip(); @@ -525,7 +538,7 @@ std::tuple<bool, absl::string_view> DeduceFlagValue(const CommandLineFlag& flag, // --my_string_var --foo=bar // We look for a flag of std::string type, whose value begins with a // dash and corresponds to known flag or standalone --. - if (value[0] == '-' && flag.IsOfType<std::string>()) { + if (!value.empty() && value[0] == '-' && flag.IsOfType<std::string>()) { auto maybe_flag_name = std::get<0>(SplitNameAndValue(value.substr(1))); if (maybe_flag_name.empty() || @@ -751,5 +764,5 @@ std::vector<char*> ParseCommandLine(int argc, char* argv[]) { flags_internal::OnUndefinedFlag::kAbortIfUndefined); } -} // inline namespace lts_2019_08_08 +ABSL_NAMESPACE_END } // namespace absl |