Skip to content

Commit 7331b77

Browse files
Fix C++ ifndef_guard printer to also convert "-" to "_".
PiperOrigin-RevId: 679648401
1 parent d81e6f7 commit 7331b77

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/google/protobuf/compiler/cpp/ifndef_guard.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ std::string MakeIfdefGuardIdentifier(const absl::string_view header_path) {
3030
{
3131
{"/", "_"},
3232
{".", "_"},
33+
{"-", "_"},
3334
})),
3435
"_");
3536
}

src/google/protobuf/compiler/cpp/ifndef_guard_unittest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TEST_F(IfnDefGuardTest, Basic) {
3636
{
3737
io::Printer printer(output(), '$');
3838

39-
const IfdefGuardPrinter ifdef_guard(&printer, "A/B/E/alpha");
39+
const IfdefGuardPrinter ifdef_guard(&printer, "A/B-E.alpha");
4040

4141
EXPECT_FALSE(printer.failed());
4242
}

0 commit comments

Comments
 (0)