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

leon...@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

Attachment: pgpfn5tx5Lbty.pgp
Description: OpenPGP digital signature

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to