Re: %j for printf(9)

Dima Dorfman <[email protected]>
Newsgroups gmane.os.freebsd.devel.audit
Message-ID <[email protected]>
Dag-Erling Smorgrav <[email protected]> wrote:
> Dima Dorfman <[email protected]> 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 [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.