[libcxx-commits] [PATCH] D113597: [libcxx] Update width adjustment for __format_unsigned_integral

Brian Cain via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 10 12:32:19 PST 2021


androm3da updated this revision to Diff 386283.
androm3da retitled this revision from "[libcxx] Change the type of __size to match __width" to "[libcxx] Update width adjustment for __format_unsigned_integral".
androm3da edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113597/new/

https://reviews.llvm.org/D113597

Files:
  libcxx/include/__format/formatter_integral.h


Index: libcxx/include/__format/formatter_integral.h
===================================================================
--- libcxx/include/__format/formatter_integral.h
+++ libcxx/include/__format/formatter_integral.h
@@ -404,8 +404,12 @@
       __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
       this->__alignment = _Flags::_Alignment::__right;
       this->__fill = _CharT('0');
-      unsigned __size = __first - __begin;
-      this->__width -= _VSTD::min(__size, this->__width);
+      auto __size = __first - __begin;
+      if (this->__width <= __size) {
+          this->__width = 0;
+      } else {
+          this->__width -= __size;
+      }
     }
 
     return __write(__first, __last, _VSTD::move(__out_it));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113597.386283.patch
Type: text/x-patch
Size: 744 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211110/9864599e/attachment.bin>


More information about the libcxx-commits mailing list