[libc-commits] [PATCH] D155113: [libc][NFC] reuse variable in printf string conv

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jul 18 16:31:07 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4d4e18f4ac67: [libc][NFC] reuse variable in printf string conv (authored by michaelrj).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155113

Files:
  libc/src/stdio/printf_core/char_converter.h
  libc/src/stdio/printf_core/string_converter.h


Index: libc/src/stdio/printf_core/string_converter.h
===================================================================
--- libc/src/stdio/printf_core/string_converter.h
+++ libc/src/stdio/printf_core/string_converter.h
@@ -39,7 +39,7 @@
   // If the padding is on the left side, write the spaces first.
   if (padding_spaces > 0 &&
       (to_conv.flags & FormatFlags::LEFT_JUSTIFIED) == 0) {
-    RET_IF_RESULT_NEGATIVE(writer->write(' ', to_conv.min_width - string_len));
+    RET_IF_RESULT_NEGATIVE(writer->write(' ', padding_spaces));
   }
 
   RET_IF_RESULT_NEGATIVE(writer->write(
@@ -48,7 +48,7 @@
   // If the padding is on the right side, write the spaces last.
   if (padding_spaces > 0 &&
       (to_conv.flags & FormatFlags::LEFT_JUSTIFIED) != 0) {
-    RET_IF_RESULT_NEGATIVE(writer->write(' ', to_conv.min_width - string_len));
+    RET_IF_RESULT_NEGATIVE(writer->write(' ', padding_spaces));
   }
   return WRITE_OK;
 }
Index: libc/src/stdio/printf_core/char_converter.h
===================================================================
--- libc/src/stdio/printf_core/char_converter.h
+++ libc/src/stdio/printf_core/char_converter.h
@@ -29,7 +29,7 @@
   // If the padding is on the left side, write the spaces first.
   if (padding_spaces > 0 &&
       (to_conv.flags & FormatFlags::LEFT_JUSTIFIED) == 0) {
-    RET_IF_RESULT_NEGATIVE(writer->write(' ', to_conv.min_width - string_len));
+    RET_IF_RESULT_NEGATIVE(writer->write(' ', padding_spaces));
   }
 
   RET_IF_RESULT_NEGATIVE(writer->write(c));
@@ -37,7 +37,7 @@
   // If the padding is on the right side, write the spaces last.
   if (padding_spaces > 0 &&
       (to_conv.flags & FormatFlags::LEFT_JUSTIFIED) != 0) {
-    RET_IF_RESULT_NEGATIVE(writer->write(' ', to_conv.min_width - string_len));
+    RET_IF_RESULT_NEGATIVE(writer->write(' ', padding_spaces));
   }
 
   return WRITE_OK;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155113.541778.patch
Type: text/x-patch
Size: 1871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230718/1a1d3865/attachment.bin>


More information about the libc-commits mailing list