Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 May 2002 21:31:54 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Dag-Erling Smorgrav <des@ofug.org>
Cc:        Dima Dorfman <dima@trit.org>, <audit@FreeBSD.ORG>
Subject:   Re: %j for printf(9)
Message-ID:  <20020531205803.L32389-100000@gamplex.bde.org>
In-Reply-To: <xzpsn48d8sz.fsf@flood.ping.uio.no>

next in thread | previous in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020531205803.L32389-100000>