Re: %j for printf(9)

Bruce Evans <[email protected]>
Newsgroups gmane.os.freebsd.devel.audit
Message-ID <[email protected]>
On 31 May 2002, Dag-Erling Smorgrav wrote:

> Bruce, does this look OK?
>
> fetch_nosign:
>                         if (jflag)
>                                 num = va_arg(ap, uintmax_t);
>                         else if (qflag)
>                                 num = va_arg(ap, u_quad_t);
>                         else if (lflag)
>                                 num = va_arg(ap, u_long);
>                         else
>                                 num = va_arg(ap, u_int);
>                         goto nosign;
> fetch_number:
>                         if (jflag)
>                                 num = va_arg(ap, intmax_t);
>                         else if (qflag)
>                                 num = sign ? (uintmax_t)va_arg(ap, quad_t) :
>                                     va_arg(ap, u_quad_t);
>                         else if (lflag)
>                                 num = sign ? (uintmax_t)va_arg(ap, long) :
>                                     va_arg(ap, u_long);
>                         else
>                                 num = sign ? (uintmax_t)va_arg(ap, int) :
>                                     va_arg(ap, u_int);
>                         goto number;

OK.

I don't remember all the context for this.  Is everything restructured so
that all the va_arg()'s for fetching integers are in the above patch?
If so, consider the following further restructurings:

- merge fetch_nosign with nosign (rename it to something like
  handle_unsigned) and use it handle all the unsigned cases that are now
  handled by fetch_number.
- rename fetch_number to handle_signed and use it for only the signed cases
  (%d and %+z).
- don't bother explicitly casting to uintmax_t for the signed cases.  In
  -current, these casts are used for %+z but not for %d.

Bruce


To Unsubscribe: send mail to [email protected]
with "unsubscribe freebsd-audit" in the body of the message
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.