Skip to content

Commit

Permalink
Fixes #168: Now supporting the case of size_t being of smaller size…
Browse files Browse the repository at this point in the history
… than `long` (e.g. for the msp430-elf-gcc target)
  • Loading branch information
eyalroz committed Nov 21, 2023
1 parent f7774aa commit 5e9b4da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ Notes:

* The `L` modifier, for `long double`, is not currently supported.
* A `"%zd"` or `"%zi"` takes a signed integer of the same size as `size_t`.
* The implementation currently assumes each of `intmax_t`, signed `size_t`, and `ptrdiff_t` has the same size as `long int` or as `long long int`. If this is not the case for your platform, please open an issue.
* The implementation currently assumes `intmax_t` and `ptrdiff_t` each has the same size as either `long int` or `long long int`. If this is not the case for your platform, please open an issue.
* The `Ixx` length modifiers are not in the C (nor C++) standard, but are somewhat popular, as it makes it easier to handle integer types of specific size. One must specify the argument size in bits immediately after the `I`. The printing is "integer-promotion-safe", i.e. the fact that an `int8_t` may actually be passed in promoted into a larger `int` will not prevent it from being printed using its original value.

### Return Value
Expand Down
2 changes: 1 addition & 1 deletion src/printf/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ static inline void format_string_loop(output_gadget_t* output, const char* forma
ADVANCE_IN_FORMAT_STRING(format);
break;
case 'z' :
flags |= (sizeof(size_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG);
flags |= (sizeof(size_t) <= sizeof(int) ) ? FLAGS_INT : (sizeof(size_t) == sizeof(long)) ? FLAGS_LONG : FLAGS_LONG_LONG;
ADVANCE_IN_FORMAT_STRING(format);
break;
default:
Expand Down

0 comments on commit 5e9b4da

Please sign in to comment.