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. It is documented that The variable width or precision field (an asterisk * symbol) is not realized and will to abort the output. But it's unclear from this whether the absence is deliberate, or simply not implemented yet. Would folk be amenable to a patch to add this feature? I have an (as-yet untested) attempt at it it. I don't think it would massively increase code size, and it doesn't consume any more RAM at runtime. But I thought I'd ask, in case there's some specific reason for its absence. ----- === modified file 'libc/stdio/vfprintf.c' --- libc/stdio/vfprintf.c 2017-10-17 19:56:22 +0000 +++ libc/stdio/vfprintf.c 2017-10-17 19:57:23 +0000 @@ -344,6 +344,12 @@ flags |= FL_WIDTH; continue; } + if (c == '*') { + if (flags & FL_PREC) + prec = va_arg(ap, int); + else + width = va_arg(ap, int); + } if (c == '.') { if (flags & FL_PREC) goto ret; -- Paul "LeoNerd" Evans leon...@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
pgpBgHtAVDMf7.pgp
Description: OpenPGP digital signature
_______________________________________________ AVR-libc-dev mailing list AVR-libc-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-libc-dev