Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 May 2002 00:16:14 +0000
From:      Dima Dorfman <dima@trit.org>
To:        Dag-Erling Smorgrav <des@ofug.org>
Cc:        audit@freebsd.org
Subject:   Re: %j for printf(9) 
Message-ID:  <20020528001615.4BAC93E5E@turbine.trit.org>
In-Reply-To: <xzpr8k08ifs.fsf@flood.ping.uio.no>; from des@ofug.org on "25 May 2002 15:29:11 %2B0200"

next in thread | previous in thread | raw e-mail | index | archive | help
Dag-Erling Smorgrav <des@ofug.org> wrote:
> Dima Dorfman <dima@trit.org> writes:
> > Attached is a patch that implements the %j length modifier in
> > printf(9).
> 
> Here's an alternative (IMHO less disruptive) patch, which also fixes
> the default case.

I still like my restructure, but since other people don't seem to
share my opinion, I'm fine doing it another (your) way.  That said, I
think your patch has some bugs that mine doesn't.  For example, this:

	printf("%ld\n", -4);

yields "4294967292" with your patch, but not with mine (mine, and
printf(3), yield "-4").  I think the attached patch (relative to
subr_prf.c *with* your patch applied) fixes it.

Thanks.

--- subr_prf_des.c	Mon May 27 23:55:45 2002
+++ subr_prf.c	Tue May 28 00:09:30 2002
@@ -658,19 +658,19 @@
 			if (jflag)
 				num = va_arg(ap, uintmax_t);
 			else if (qflag)
-				num = va_arg(ap, u_quad_t);
+				num = (u_quad_t)va_arg(ap, u_quad_t);
 			else if (lflag)
-				num = va_arg(ap, u_long);
+				num = (u_long)va_arg(ap, u_long);
 			else
-				num = va_arg(ap, u_int);
+				num = (u_int)va_arg(ap, u_int);
 			goto nosign;
 fetch_number:
 			if (jflag)
-				num = va_arg(ap, uintmax_t);
+				num = va_arg(ap, intmax_t);
 			else if (qflag)
-				num = va_arg(ap, u_quad_t);
+				num = (quad_t)va_arg(ap, quad_t);
 			else if (lflag)
-				num = va_arg(ap, u_long);
+				num = (long)va_arg(ap, long);
 			else
 				num = sign ? (uintmax_t)va_arg(ap, int) :
 				    va_arg(ap, u_int);

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?20020528001615.4BAC93E5E>