[libc-commits] [libc] [libc] Support ls in printf (PR #178841)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Wed Feb 4 14:47:12 PST 2026


================
@@ -50,7 +101,48 @@ LIBC_INLINE int convert_string(Writer<write_mode> *writer,
     RET_IF_RESULT_NEGATIVE(writer->write(' ', padding_spaces));
   }
 
-  RET_IF_RESULT_NEGATIVE(writer->write({(str_ptr), string_len}));
+  if (to_conv.length_modifier == LengthModifier::l) {
+#ifndef LIBC_COPT_PRINTF_DISABLE_WIDE
+    const wchar_t *wstr_ptr =
+        reinterpret_cast<const wchar_t *>(to_conv.conv_val_ptr);
+
+#ifndef LIBC_COPT_PRINTF_NO_NULLPTR_CHECKS
+    if (wstr_ptr == nullptr) {
+      wstr_ptr = L"(null)";
+    }
----------------
michaelrj-google wrote:

since we assume that wchar is UTF-32 (or maybe UTF-16) we don't actually need a separate `(null)` string here. We could treat it the same as the non-wide null conversion.

https://github.com/llvm/llvm-project/pull/178841


More information about the libc-commits mailing list