diff options
Diffstat (limited to 'absl/flags/usage_config.cc')
-rw-r--r-- | absl/flags/usage_config.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/absl/flags/usage_config.cc b/absl/flags/usage_config.cc index 2d837ec5907c..0d21bce6a9ad 100644 --- a/absl/flags/usage_config.cc +++ b/absl/flags/usage_config.cc @@ -50,10 +50,15 @@ namespace { bool ContainsHelpshortFlags(absl::string_view filename) { // By default we only want flags in binary's main. We expect the main // routine to reside in <program>.cc or <program>-main.cc or - // <program>_main.cc, where the <program> is the name of the binary. + // <program>_main.cc, where the <program> is the name of the binary + // (without .exe on Windows). auto suffix = flags_internal::Basename(filename); - if (!absl::ConsumePrefix(&suffix, - flags_internal::ShortProgramInvocationName())) + auto program_name = flags_internal::ShortProgramInvocationName(); + absl::string_view program_name_ref = program_name; +#if defined(_WIN32) + absl::ConsumeSuffix(&program_name_ref, ".exe"); +#endif + if (!absl::ConsumePrefix(&suffix, program_name_ref)) return false; return absl::StartsWith(suffix, ".") || absl::StartsWith(suffix, "-main.") || absl::StartsWith(suffix, "_main."); |