[PATCH] printf: allow 0 as a flag and allow multiple flags

Ron Yorston rmy at pobox.com
Sun Dec 19 14:58:25 UTC 2021


David Laight wrote:
>Or:
>				tmp = strspn(f, "-+ #0");
>				direc_length += tmp - f;
>				f = tmp;

Yes, that seems to work too, and it saves 28 bytes.  Though since
strspn() returns the length of the initial segment it needs to be:

   size_t tmp;
   ...
   tmp = strspn(f, "-+ #0");                                         
   direc_length += tmp;                                             
   f += tmp;

>Except that I'd have thought it would need to remember which flags are set.

They're retained in the format string which is pointed to by direc_start.

Ron


More information about the busybox mailing list