summaryrefslogtreecommitdiff
path: root/absl/strings/ascii.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-08-17 08:34:34 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-08-17 08:35:16 -0700
commit934f613818ffcb26c942dff4a80be9a4031c662c (patch)
treeef5ce22bc64d4758de1d7e339e6b4b70d8ff3e09 /absl/strings/ascii.cc
parent547802119dfa444540d8f2bb8a9f50bf64252a0f (diff)
Fix "unsafe narrowing" warnings in absl, 4/n.
Addresses failures with the following, in some files: -Wshorten-64-to-32 -Wimplicit-int-conversion -Wsign-compare -Wsign-conversion -Wtautological-unsigned-zero-compare (This specific CL focuses on .cc files in strings/, except /internal/.) Bug: chromium:1292951 PiperOrigin-RevId: 468205572 Change-Id: Ifce3f1a7a4b2b2c359bf7700a11279bebfef8a15
Diffstat (limited to 'absl/strings/ascii.cc')
-rw-r--r--absl/strings/ascii.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/absl/strings/ascii.cc b/absl/strings/ascii.cc
index 93bb03e9..868df2d1 100644
--- a/absl/strings/ascii.cc
+++ b/absl/strings/ascii.cc
@@ -157,13 +157,13 @@ ABSL_DLL const char kToUpper[256] = {
void AsciiStrToLower(std::string* s) {
for (auto& ch : *s) {
- ch = absl::ascii_tolower(ch);
+ ch = absl::ascii_tolower(static_cast<unsigned char>(ch));
}
}
void AsciiStrToUpper(std::string* s) {
for (auto& ch : *s) {
- ch = absl::ascii_toupper(ch);
+ ch = absl::ascii_toupper(static_cast<unsigned char>(ch));
}
}
@@ -183,17 +183,17 @@ void RemoveExtraAsciiWhitespace(std::string* str) {
for (; input_it < input_end; ++input_it) {
if (is_ws) {
// Consecutive whitespace? Keep only the last.
- is_ws = absl::ascii_isspace(*input_it);
+ is_ws = absl::ascii_isspace(static_cast<unsigned char>(*input_it));
if (is_ws) --output_it;
} else {
- is_ws = absl::ascii_isspace(*input_it);
+ is_ws = absl::ascii_isspace(static_cast<unsigned char>(*input_it));
}
*output_it = *input_it;
++output_it;
}
- str->erase(output_it - &(*str)[0]);
+ str->erase(static_cast<size_t>(output_it - &(*str)[0]));
}
ABSL_NAMESPACE_END