diff --git a/format.cc b/format.cc index a9577028..5f696799 100644 --- a/format.cc +++ b/format.cc @@ -444,7 +444,7 @@ class BasicArgFormatter : public ArgVisitor { typedef typename BasicWriter::CharPtr CharPtr; Char fill = internal::CharTraits::cast(spec_.fill()); CharPtr out = CharPtr(); - const int CHAR_WIDTH = 1; + const unsigned CHAR_WIDTH = 1; if (spec_.width_ > CHAR_WIDTH) { out = writer_.grow_buffer(spec_.width_); if (spec_.align_ == ALIGN_RIGHT) { diff --git a/format.h b/format.h index 68c7e51b..29a7f0f2 100644 --- a/format.h +++ b/format.h @@ -292,7 +292,9 @@ class BasicStringRef { int compare(BasicStringRef other) const { std::size_t size = std::min(size_, other.size_); int result = std::char_traits::compare(data_, other.data_, size); - return result != 0 ? result : size_ - other.size_; + if (result == 0) + result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1); + return result; } friend bool operator==(BasicStringRef lhs, BasicStringRef rhs) {