about summary refs log tree commit diff
path: root/absl
diff options
context:
space:
mode:
Diffstat (limited to 'absl')
-rw-r--r--absl/flags/flag.h2
-rw-r--r--absl/flags/internal/usage.cc18
-rw-r--r--absl/flags/internal/usage_test.cc33
-rw-r--r--absl/time/internal/cctz/src/time_zone_posix.cc10
-rw-r--r--absl/types/optional_test.cc2
5 files changed, 57 insertions, 8 deletions
diff --git a/absl/flags/flag.h b/absl/flags/flag.h
index 6c9f48765cfa..36c771cf49b1 100644
--- a/absl/flags/flag.h
+++ b/absl/flags/flag.h
@@ -217,7 +217,7 @@ void SetFlag(absl::Flag<T>* flag, const V& v) {
 // global name for FLAGS_no<flag_name> symbol, thus preventing the possibility
 // of defining two flags with names foo and nofoo.
 #define ABSL_FLAG_IMPL(Type, name, default_value, help)             \
-  namespace absl {}                                                 \
+  namespace absl /* block flags in namespaces */ {}                 \
   ABSL_FLAG_IMPL_DECLARE_DEF_VAL_WRAPPER(name, Type, default_value) \
   ABSL_FLAG_IMPL_DECLARE_HELP_WRAPPER(name, help)                   \
   ABSL_CONST_INIT absl::Flag<Type> FLAGS_##name(                    \
diff --git a/absl/flags/internal/usage.cc b/absl/flags/internal/usage.cc
index aac02db6c27a..03048514ae0b 100644
--- a/absl/flags/internal/usage.cc
+++ b/absl/flags/internal/usage.cc
@@ -111,8 +111,16 @@ class FlagHelpPrettyPrinter {
 
     std::vector<absl::string_view> tokens;
     if (wrap_line) {
-      tokens = absl::StrSplit(str, absl::ByAnyChar(" \f\n\r\t\v"),
-                              absl::SkipEmpty());
+      for (auto line : absl::StrSplit(str, absl::ByAnyChar("\n\r"))) {
+        if (!tokens.empty()) {
+          // Keep line separators in the input std::string.
+          tokens.push_back("\n");
+        }
+        for (auto token :
+             absl::StrSplit(line, absl::ByAnyChar(" \t"), absl::SkipEmpty())) {
+          tokens.push_back(token);
+        }
+      }
     } else {
       tokens.push_back(str);
     }
@@ -120,6 +128,12 @@ class FlagHelpPrettyPrinter {
     for (auto token : tokens) {
       bool new_line = (line_len_ == 0);
 
+      // Respect line separators in the input std::string.
+      if (token == "\n") {
+        EndLine();
+        continue;
+      }
+
       // Write the token, ending the std::string first if necessary/possible.
       if (!new_line && (line_len_ + token.size() >= max_line_len_)) {
         EndLine();
diff --git a/absl/flags/internal/usage_test.cc b/absl/flags/internal/usage_test.cc
index 5e5f7a84cc43..781e1d2b16ab 100644
--- a/absl/flags/internal/usage_test.cc
+++ b/absl/flags/internal/usage_test.cc
@@ -48,6 +48,14 @@ std::string AbslUnparseFlag(const UDT&) { return "UDT{}"; }
 ABSL_FLAG(UDT, usage_reporting_test_flag_05, {},
           "usage_reporting_test_flag_05 help message");
 
+ABSL_FLAG(
+    std::string, usage_reporting_test_flag_06, {},
+    "usage_reporting_test_flag_06 help message.\n"
+    "\n"
+    "Some more help.\n"
+    "Even more long long long long long long long long long long long long "
+    "help message.");
+
 namespace {
 
 namespace flags = absl::flags_internal;
@@ -173,6 +181,11 @@ TEST_F(UsageReportingTest, TestFlagsHelpHRF) {
       default: 1000000000000004;
     -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message);
       default: UDT{};
+    -usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message.
+
+      Some more help.
+      Even more long long long long long long long long long long long long help
+      message.); default: "";
 )";
 
   std::stringstream test_buf_01;
@@ -244,6 +257,11 @@ TEST_F(UsageReportingTest, TestUsageFlag_helpshort) {
       default: 1000000000000004;
     -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message);
       default: UDT{};
+    -usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message.
+
+      Some more help.
+      Even more long long long long long long long long long long long long help
+      message.); default: "";
 )");
 }
 
@@ -268,6 +286,11 @@ TEST_F(UsageReportingTest, TestUsageFlag_help) {
       default: 1000000000000004;
     -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message);
       default: UDT{};
+    -usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message.
+
+      Some more help.
+      Even more long long long long long long long long long long long long help
+      message.); default: "";
 
 Try --helpfull to get a list of all flags.
 )");
@@ -294,6 +317,11 @@ TEST_F(UsageReportingTest, TestUsageFlag_helppackage) {
       default: 1000000000000004;
     -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message);
       default: UDT{};
+    -usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message.
+
+      Some more help.
+      Even more long long long long long long long long long long long long help
+      message.); default: "";
 
 Try --helpfull to get a list of all flags.
 )");
@@ -354,6 +382,11 @@ TEST_F(UsageReportingTest, TestUsageFlag_helpon) {
       default: 1000000000000004;
     -usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message);
       default: UDT{};
+    -usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message.
+
+      Some more help.
+      Even more long long long long long long long long long long long long help
+      message.); default: "";
 )");
 }
 
diff --git a/absl/time/internal/cctz/src/time_zone_posix.cc b/absl/time/internal/cctz/src/time_zone_posix.cc
index 993901acfa22..038740e1d67b 100644
--- a/absl/time/internal/cctz/src/time_zone_posix.cc
+++ b/absl/time/internal/cctz/src/time_zone_posix.cc
@@ -100,9 +100,9 @@ const char* ParseDateTime(const char* p, PosixTransition* res) {
           int weekday = 0;
           if ((p = ParseInt(p + 1, 0, 6, &weekday)) != nullptr) {
             res->date.fmt = PosixTransition::M;
-            res->date.m.month = static_cast<int_fast8_t>(month);
-            res->date.m.week = static_cast<int_fast8_t>(week);
-            res->date.m.weekday = static_cast<int_fast8_t>(weekday);
+            res->date.m.month = static_cast<std::int_fast8_t>(month);
+            res->date.m.week = static_cast<std::int_fast8_t>(week);
+            res->date.m.weekday = static_cast<std::int_fast8_t>(weekday);
           }
         }
       }
@@ -110,13 +110,13 @@ const char* ParseDateTime(const char* p, PosixTransition* res) {
       int day = 0;
       if ((p = ParseInt(p + 1, 1, 365, &day)) != nullptr) {
         res->date.fmt = PosixTransition::J;
-        res->date.j.day = static_cast<int_fast16_t>(day);
+        res->date.j.day = static_cast<std::int_fast16_t>(day);
       }
     } else {
       int day = 0;
       if ((p = ParseInt(p, 0, 365, &day)) != nullptr) {
         res->date.fmt = PosixTransition::N;
-        res->date.j.day = static_cast<int_fast16_t>(day);
+        res->date.n.day = static_cast<std::int_fast16_t>(day);
       }
     }
   }
diff --git a/absl/types/optional_test.cc b/absl/types/optional_test.cc
index 221c314593ad..e6a36eb8e26f 100644
--- a/absl/types/optional_test.cc
+++ b/absl/types/optional_test.cc
@@ -1628,6 +1628,7 @@ TEST(optionalTest, AssignmentConstraints) {
   EXPECT_TRUE(absl::is_copy_assignable<absl::optional<AnyLike>>::value);
 }
 
+#if !defined(__EMSCRIPTEN__)
 struct NestedClassBug {
   struct Inner {
     bool dummy = false;
@@ -1650,5 +1651,6 @@ TEST(optionalTest, InPlaceTSFINAEBug) {
   o.emplace();
   EXPECT_TRUE(o.has_value());
 }
+#endif  // !defined(__EMSCRIPTEN__)
 
 }  // namespace