From 7331b770978d55e6753a286187a511de86452e1a Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Fri, 27 Sep 2024 10:45:30 -0700 Subject: [PATCH] Fix C++ ifndef_guard printer to also convert "-" to "_". PiperOrigin-RevId: 679648401 --- src/google/protobuf/compiler/cpp/ifndef_guard.cc | 1 + src/google/protobuf/compiler/cpp/ifndef_guard_unittest.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/google/protobuf/compiler/cpp/ifndef_guard.cc b/src/google/protobuf/compiler/cpp/ifndef_guard.cc index bc04eecebf..a8604e0675 100644 --- a/src/google/protobuf/compiler/cpp/ifndef_guard.cc +++ b/src/google/protobuf/compiler/cpp/ifndef_guard.cc @@ -30,6 +30,7 @@ std::string MakeIfdefGuardIdentifier(const absl::string_view header_path) { { {"/", "_"}, {".", "_"}, + {"-", "_"}, })), "_"); } diff --git a/src/google/protobuf/compiler/cpp/ifndef_guard_unittest.cc b/src/google/protobuf/compiler/cpp/ifndef_guard_unittest.cc index 4e4a823845..b63c86b6a7 100644 --- a/src/google/protobuf/compiler/cpp/ifndef_guard_unittest.cc +++ b/src/google/protobuf/compiler/cpp/ifndef_guard_unittest.cc @@ -36,7 +36,7 @@ TEST_F(IfnDefGuardTest, Basic) { { io::Printer printer(output(), '$'); - const IfdefGuardPrinter ifdef_guard(&printer, "A/B/E/alpha"); + const IfdefGuardPrinter ifdef_guard(&printer, "A/B-E.alpha"); EXPECT_FALSE(printer.failed()); }