[libc-commits] [libc] [libc] Support %lc in printf (PR #169983)
Shubh Pachchigar via libc-commits
libc-commits at lists.llvm.org
Tue Dec 23 23:37:32 PST 2025
================
@@ -33,7 +41,27 @@ LIBC_INLINE int convert_char(Writer<write_mode> *writer,
RET_IF_RESULT_NEGATIVE(writer->write(' ', padding_spaces));
}
- RET_IF_RESULT_NEGATIVE(writer->write(c));
+#ifndef LIBC_COPT_PRINTF_DISABLE_WIDE
+ if (to_conv.length_modifier == LengthModifier::l) {
+ wint_t wi = static_cast<wint_t>(to_conv.conv_val_raw);
+
+ if (wi == WEOF) {
+ return -1;
----------------
shubhe25p wrote:
i found this in the C standard:
> When wc is not a valid wide character, an encoding error occurs. If an encoding error occurs (including too few bytes), the error indicator for the stream is set and the value of the macro EILSEQ is stored in errno and the fgetwc function returns WEOF
Does that mean we set libc_errno to EILSEQ and return -1 and not INT_CONVERSION_ERROR as it corresponds to ERANGE?
https://github.com/llvm/llvm-project/pull/169983
More information about the libc-commits
mailing list