sprintf does not appear to correctly implement format specifiers including width characters:
sprintf(cBuffer, "%03d", 4);
produces 0x30 0x33 0x00 rather than the expected 0x30 0x30 0x34.
Compiled using:
sdcc -mpic16 -p18f2320 7seg-sp.c
sdcc version:
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.7.0 #4818 (May 31 2007) (MINGW32)
using gputils:
gpasm-0.13.4 beta
gplink-0.13.4 alpha
Apologies for the size of the attached code, however I wanted to make sure I didn't drop anything important by editing it for this report.
Full code exhibiting problem
Logged In: YES
user_id=1115835
Originator: NO
The pic16 library sources indicate that the supported format specifiers (for vfprintf, which is used to implement the whole *printf-family) comprise
%%, %[u]hb, %[u]b, %[u]lb, %[u]hd, %[u]d, %[u]ld, %[u]hx, %[u]hX, %[u]x, %[u]X, %[u]lx, %[u]lX, %[u]ho, %[u]o, %[u]lo, %c, and %s,
where `u' is an optional modifier indicating unsigned values, `h' denotes byte wide arguments (8 bit), `l' long arguments (32 bit) and no modifier standard int (16 bit) arguments, which are emitted as (b)inary, (d)ecimal, he(x)adecimal in lower- or uppoercase letters, or (o)ctal besides the literal (%) sign output, a single ASCII (c)haracter or a NUL terminated (s)tring.
Width and padding modifiers are nit supported by the PIC16 library version---feel free to use a different implementation, just link it prior to the library to your project.
If I should happen to come up with a compact fully fledged, SUSv3 and POSIX compatible printf implementation, I will add it to the library... or sell it for muuuch money ;-)
Regards,
Raphael
Not sure how to proceed: is this a feature request? really a bug, despite being documented in the sources?!? Setting this to pending...
Logged In: YES
user_id=1312539
Originator: NO
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 30 days (the time period specified by
the administrator of this Tracker).