summaryrefslogtreecommitdiff
path: root/libc/docs/dev/printf_behavior.rst
AgeCommit message (Collapse)Author
2025-01-23[libc][NFC] Strip all training whitespace and missing newlines (#124163)Joseph Huber
2024-09-19[libc] Add printf strerror conversion (%m) (#105891)Michael Jones
This patch adds the %m conversion to printf, which prints the strerror(errno). Explanation of why is below, this patch also updates the docs, tests, and build system to accomodate this. The standard for syslog in posix specifies it uses the same format as printf, but adds %m which prints the error message string for the current value of errno. For ease of implementation, it's standard practice for libc implementers to just add %m to printf instead of creating a separate parser for syslog.
2024-08-02[libc] Fix printf handling of INT_MIN width (#101729)Michael Jones
Prevously, if INT_MIN was passed as a wildcard width to a printf conversion the parser would attempt to negate it to get the positive width (and set the left justify flag), but it would underflow and the width would be treated as 0. This patch corrects the issue by instead treating a width of INT_MIN as identical to -INT_MAX. Also includes docs changes to explain this behavior and adding b to the list of int conversions.
2024-03-29Add bit width length modifier to printf (#82461)Om Prakaash
Resolves #81685. This adds support for wN and wfN length modifiers in fprintf.
2024-03-19[libc] Make 'printf' converter output "(null)" instead of "null" (#85845)Joseph Huber
Summary: Currently we print `null` for the null pointer in a `%s` expression. Although it's not defined by the standard, other implementations choose to use `(null)` to indicate this. We also currently print `(nullptr)` so I think it's more consistent to use parens in both cases.
2024-02-27[libc] Add fixed point support to printf (#82707)Michael Jones
This patch adds the r, R, k, and K conversion specifiers to printf, with accompanying tests. They are guarded behind the LIBC_COPT_PRINTF_DISABLE_FIXED_POINT flag as well as automatic fixed point support detection.
2024-02-23[libc][NFC] Remove all trailing spaces from libc (#82831)Joseph Huber
Summary: There are a lot of random training spaces on various lines. This patch just got rid of all of them with `sed 's/\ \+$//g'.
2024-01-25[libc] Move printf long double to simple calc (#75414)michaelrj-google
The Ryu algorithm is very fast with its table, but that table grows too large for long doubles. This patch adds a method of calculating the digits of long doubles using just wide integers and fast modulo operations. This results in significant performance improvements vs the previous int calc mode, while taking up a similar amound of peak memory. It will be slow in some %e/%g cases, but reasonable fast for %f with no loss of accuracy.
2023-09-22[libc] Refactor scanf reader to match printf (#66023)michaelrj-google
In a previous patch, the printf writer was rewritten to use a single writer class with a buffer and a callback hook. This patch refactors scanf's reader to match conceptually.
2023-09-13[libc][docs] Printf behavior docMichael Jones
In the document on undefined behavior, I noted that writing down your decisions is very important. This document contains all the information for compile flags and undefined behavior for our printf. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D158311