Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Options used both in CMake and in the library source code via a preprocessor def
| SUPPORT_WRITEBACK_SPECIFIER | YES | Support the length write-back specifier (%n) |
| SUPPORT_LONG_LONG | YES | Support long long integral types (allows for the ll length modifier and affects %p) |
| USE_DOUBLE_INTERNALLY | YES | Use the `double` for internal floating-point calculations (rather than using the single-precision `float` type |
| NO_STACK_BUFFER | NO | Define buffers as static |

In the source files themselves, these options become preprocessor definitions with a `PRINTF_` prefix; the boolean ones have value `1` OR `0` for YES or NO respectively; and the aliasing option translates into one of three definitions: `ALIAS_STANDARD_FUNCTION_NAMES_NONE`, `ALIAS_STANDARD_FUNCTION_NAMES_SOFT` or `ALIAS_STANDARD_FUNCTION_NAMES_HARD`.

Expand Down
8 changes: 8 additions & 0 deletions src/printf/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,11 @@ static void print_integer_finalization(output_gadget_t* output, char* buf, print
/* An internal itoa-like function */
static void print_integer(output_gadget_t* output, printf_unsigned_value_t value, bool negative, numeric_base_t base, printf_size_t precision, printf_size_t width, printf_flags_t flags)
{
#ifdef PRINTF_NO_STACK_BUFFER
static char buf[PRINTF_INTEGER_BUFFER_SIZE] = { 0 };
#else
char buf[PRINTF_INTEGER_BUFFER_SIZE];
#endif // PRINTF_NO_STACK_BUFFER
printf_size_t len = 0U;

if (!value) {
Expand Down Expand Up @@ -1156,7 +1160,11 @@ static void print_exponential_number(output_gadget_t* output, floating_point_t n

static void print_floating_point(output_gadget_t* output, floating_point_t value, printf_size_t precision, printf_size_t width, printf_flags_t flags, bool prefer_exponential)
{
#ifdef PRINTF_NO_STACK_BUFFER
static char buf[PRINTF_DECIMAL_BUFFER_SIZE] = { 0 };
#else
char buf[PRINTF_DECIMAL_BUFFER_SIZE];
#endif // PRINTF_NO_STACK_BUFFER
printf_size_t len = 0U;

/* test for special values */
Expand Down