summaryrefslogtreecommitdiff
path: root/abseil-cpp/absl/strings/internal/str_format/bind.cc
diff options
context:
space:
mode:
Diffstat (limited to 'abseil-cpp/absl/strings/internal/str_format/bind.cc')
-rw-r--r--abseil-cpp/absl/strings/internal/str_format/bind.cc28
1 files changed, 21 insertions, 7 deletions
diff --git a/abseil-cpp/absl/strings/internal/str_format/bind.cc b/abseil-cpp/absl/strings/internal/str_format/bind.cc
index 6980ed1..77a4222 100644
--- a/abseil-cpp/absl/strings/internal/str_format/bind.cc
+++ b/abseil-cpp/absl/strings/internal/str_format/bind.cc
@@ -1,3 +1,17 @@
+// Copyright 2020 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
#include "absl/strings/internal/str_format/bind.h"
#include <cerrno>
@@ -18,7 +32,8 @@ inline bool BindFromPosition(int position, int* value,
return false;
}
// -1 because positions are 1-based
- return FormatArgImplFriend::ToInt(pack[position - 1], value);
+ return FormatArgImplFriend::ToInt(pack[static_cast<size_t>(position) - 1],
+ value);
}
class ArgContext {
@@ -42,9 +57,9 @@ inline bool ArgContext::Bind(const UnboundConversion* unbound,
const FormatArgImpl* arg = nullptr;
int arg_position = unbound->arg_position;
if (static_cast<size_t>(arg_position - 1) >= pack_.size()) return false;
- arg = &pack_[arg_position - 1]; // 1-based
+ arg = &pack_[static_cast<size_t>(arg_position - 1)]; // 1-based
- if (!unbound->flags.basic) {
+ if (unbound->flags != Flags::kBasic) {
int width = unbound->width.value();
bool force_left = false;
if (unbound->width.is_from_arg()) {
@@ -70,9 +85,8 @@ inline bool ArgContext::Bind(const UnboundConversion* unbound,
FormatConversionSpecImplFriend::SetPrecision(precision, bound);
if (force_left) {
- Flags flags = unbound->flags;
- flags.left = true;
- FormatConversionSpecImplFriend::SetFlags(flags, bound);
+ FormatConversionSpecImplFriend::SetFlags(unbound->flags | Flags::kLeft,
+ bound);
} else {
FormatConversionSpecImplFriend::SetFlags(unbound->flags, bound);
}
@@ -221,7 +235,7 @@ int FprintF(std::FILE* output, const UntypedFormatSpecImpl format,
errno = sink.error();
return -1;
}
- if (sink.count() > std::numeric_limits<int>::max()) {
+ if (sink.count() > static_cast<size_t>(std::numeric_limits<int>::max())) {
errno = EFBIG;
return -1;
}