[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] printf "%*s" format
From: |
Paul \"LeoNerd\" Evans |
Subject: |
[avr-gcc-list] printf "%*s" format |
Date: |
Sun, 3 Jul 2016 13:52:08 +0100 |
I often find it useful to be able to print a character buffer of
dynamically-known size by using some variant on
printf("%.*s", len, buf);
It appears to me that avr-libc doesn't recognise this particular flag.
Neither the documentation nor the implementation in vfprintf.c seem to
mention it. If I try it, it just gives up. E.g.
uint8_t len;
uint8_t buf[16];
...
printf("BUF=%d <%.*s>\n", len, len, buf);
I get output simply
BUF=4 <
it stops parsing at the .*, and doesn't even get as far as printing the
'>' and trailing linefeed.
Would folk be amenable to a patch to add this feature? To my eye it
doesn't look like it would be more than about a 5-line change to add
it, I don't think it would massively increase code size.
But I thought I'd ask first, in case there's some specific reason for
its absence.
--
Paul "LeoNerd" Evans
address@hidden | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
pgpjN7j2zRDNo.pgp
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-gcc-list] printf "%*s" format,
Paul \"LeoNerd\" Evans <=