Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions absl/flags/usage_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,10 @@ 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
// (without .exe on Windows).
// <program>_main.cc, where the <program> is the name of the binary.
auto suffix = flags_internal::Basename(filename);
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))
if (!absl::ConsumePrefix(&suffix,
flags_internal::ShortProgramInvocationName()))
return false;
return absl::StartsWith(suffix, ".") || absl::StartsWith(suffix, "-main.") ||
absl::StartsWith(suffix, "_main.");
Expand Down
4 changes: 0 additions & 4 deletions absl/flags/usage_config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ TEST_F(FlagsUsageConfigTest, TestGetSetFlagsUsageConfig) {
// --------------------------------------------------------------------

TEST_F(FlagsUsageConfigTest, TestContainsHelpshortFlags) {
#if defined(_WIN32)
flags::SetProgramInvocationName("usage_config_test.exe");
#else
flags::SetProgramInvocationName("usage_config_test");
#endif

auto config = flags::GetUsageConfig();
EXPECT_TRUE(config.contains_helpshort_flags("adir/cd/usage_config_test.cc"));
Expand Down