Commit Graph

14 Commits (d8350738d3ea07f8a6e129546a14ba3ef5685fca)

Author SHA1 Message Date
Marcus Chang d8350738d3 Add support for fprintf and vfprintf (#21)
Debug print is routed to stderr which relies on [v]fprintf.
This change adds support for overwriting the build-in [v]fprintf.
2019-07-04 10:46:31 +01:00
Evelyne Donnaes 96b5c1d6d4 Fixed floating point support (#24)
This PR adds:
* Support for hexadecimal printing in lower case
* Fixes to floating point printing (leading zeros in decimal part)
2019-07-02 11:09:49 +01:00
Marcus Chang 705d428fde Improve conformity
* Parse each specifier based on this pattern:
   %[flags][width][.precision][length]specifier
   http://www.cplusplus.com/reference/cstdio/printf/
 * Flags and width are still ignored.
 * Precision is supported for strings (string precision is used by Pelion Client).
 * Length is supported.
2019-04-16 04:49:44 -07:00
Alon Nof 71966b6e5a remove warning: comparison of an unsigned value (#13)
remove compile warning: comparison of an unsigned value is always true
2018-12-17 10:38:42 +00:00
Marcus Chang cbdb3fe3fd Optional SWO output instead of UART
Change the default output from STDIO UART to SWO by overriding:

    "minimal-printf.console-output": "SWO"
2018-05-06 20:07:24 -07:00
Bogdan Marinescu c6cac23960 Implementation fixes
The printf(3) man page says "The functions snprintf() and vsnprintf() do
not write more than size bytes (including the terminating null byte
('\0')).  If the output was truncated due to this limit, then the return
value is the number of characters (excluding the terminating null byte)
which would have been written to the final string if enough space had been
available." The last part of this spec (returning the number of
characters which would have been written to the string if enough space
had been available) was not implemented in minimal-printf. This PR
changes that by redirecting all the processed characters through the
"minimal_printf_putchar" helper function. This function will not write
to the buffer if there's no space left, but it will always increment the
number of written characters, in order to match the above description.
minimal_printf_putchar also contains checks for overflows, so these
checks are no longer needed in the rest of the code.

Other changes:

- In some cases, mbed_minimal_formatted_string didn't put the string
  terminator in the output buffer. This PR ensures that this always
  happens.
- Fixed a bug in printed hexadecimal numbers introduced by a previous
  commit.
- Added buffer overflow tests for snprintf.
2018-04-26 13:37:33 +03:00
Bogdan Marinescu 362dd3fbcf Bugfixes for the implementation and the compliance test
In the implementation, don't always display double hex digits when
printing with "%X". This is in line with the behaviour observed both
in mbed OS's printf (Newlib) and Linux's printf (glibc).
In the tests, always compare the baseline result with the result
returned by the minimal printf implementation, instead of comparing
with a constant value.
2018-04-26 00:05:52 +03:00
Bogdan Marinescu 2a01a54e17 Address code review issues
- Improved comments to explain the checks on 'result'.
- Check for non-NULL format specifier.
2018-03-23 10:23:48 +02:00
Bogdan Marinescu a5f07166f9 [BUGFIX][IOTUC-18] Library fixes
This commit adds mostly integer (and buffer) overflow checks for the
current buffer index (`result` variable).
2018-03-22 18:47:39 +02:00
Marcus Chang de7024f7ab Add missing include stdbool.h 2017-11-12 15:14:38 -08:00
Bogdan Marinescu 75845c3dc7 Remove references to ssize_t in the code
ssize_t doesn't exist at all in armcc.
2017-11-02 17:12:06 +00:00
Marcus Chang ab700c02df Fix file permissions 2017-10-26 13:41:32 -07:00
Marcus Chang 8ec1d473a1 Fixed bug in getting absolute value 2017-10-26 13:28:08 -07:00
Marcus Chang 3be1165fe7 Add support for width specifiers 2017-10-26 07:28:15 -07:00