Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Oct 2002 15:05:22 -0700
From:      "David O'Brien" <obrien@FreeBSD.org>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        Mike Barcroft <mike@FreeBSD.org>, freebsd-arch@FreeBSD.org, Andrew Gallatin <gallatin@cs.duke.edu>
Subject:   Re: lp64 vs lp32 printf
Message-ID:  <20021009220522.GA65943@dragon.nuxi.com>
In-Reply-To: <XFMail.20021008212240.jhb@FreeBSD.org>
References:  <20021008203120.K97120@espresso.q9media.com> <XFMail.20021008212240.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

How is this patch?


Index: contrib/gcc/c-format.c
===================================================================
RCS file: /home/ncvs/src/contrib/gcc/c-format.c,v
retrieving revision 1.5
diff -u -r1.5 c-format.c
--- contrib/gcc/c-format.c	12 Jul 2002 00:49:52 -0000	1.5
+++ contrib/gcc/c-format.c	9 Oct 2002 21:52:40 -0000
@@ -795,10 +795,12 @@
      The format %D provides a hexdump given a pointer and separator string:
      ("%6D", ptr, ":")		-> XX:XX:XX:XX:XX:XX
      ("%*D", len, ptr, " ")	-> XX XX XX XX ...
+     The format %H is a version of %x that allows for a sign
+     (e.g. -0x10 instead of 0xfffffff0, or +0x10).
    */
   { "D",   1, STD_EXT, { T89_C,  BADLEN,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      "cR" },
   { "b",   1, STD_EXT, { T89_C,  BADLEN,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp",      ""   },
-  { "rz",  0, STD_EXT, { T89_I,  BADLEN,   BADLEN,   T89_L,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp0 +#",  "i"  },
+  { "rH",  0, STD_EXT, { T89_I,  BADLEN,   BADLEN,   T89_L,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp0 +#",  "i"  },
   { NULL,  0, 0, NOLENGTHS, NULL, NULL }
 };
 
Index: share/man/man9/printf.9
===================================================================
RCS file: /home/ncvs/src/share/man/man9/printf.9,v
retrieving revision 1.3
diff -u -r1.3 printf.9
--- share/man/man9/printf.9	1 Oct 2001 16:09:25 -0000	1.3
+++ share/man/man9/printf.9	9 Oct 2002 21:55:51 -0000
@@ -66,7 +66,7 @@
 .Xr printf 3 .
 However,
 .Xr printf 9
-adds two other conversion specifiers.
+adds four conversion specifiers.
 .Pp
 The
 .Cm \&%b
@@ -90,6 +90,10 @@
 for the last bit identifier.
 .Pp
 The
+.Cm \&%r
+identifier is undocumented.
+.Pp
+The
 .Cm \&%D
 identifier is meant to assist in hexdumps.
 It requires two arguments: a
@@ -102,6 +106,12 @@
 The string is used as a delimiter between individual bytes.
 If present, a width directive will specify the number of bytes to display.
 By default, 16 bytes of data are output.
+.Pp
+The
+.Cm \&%H
+identifier is a version of
+.Cm \&%x
+that allows for a sign (e.g. -0x10 instead of 0xfffffff0, or +0x10).
 .Sh RETURN VALUES
 The
 .Fn printf
Index: sys/ddb/db_examine.c
===================================================================
RCS file: /home/ncvs/src/sys/ddb/db_examine.c,v
retrieving revision 1.29
diff -u -r1.29 db_examine.c
--- sys/ddb/db_examine.c	25 Jun 2002 15:59:24 -0000	1.29
+++ sys/ddb/db_examine.c	9 Oct 2002 21:49:55 -0000
@@ -129,7 +129,7 @@
 			    case 'z':	/* signed hex */
 				value = db_get_value(addr, size, TRUE);
 				addr += size;
-				db_printf("%-*lz", width, (long)value);
+				db_printf("%-*lH", width, (long)value);
 				break;
 			    case 'd':	/* signed decimal */
 				value = db_get_value(addr, size, TRUE);
@@ -212,8 +212,8 @@
 	    case 'x':
 		db_printf("%8lx", (unsigned long)addr);
 		break;
-	    case 'z':
-		db_printf("%8lz", (long)addr);
+	    case 'H':
+		db_printf("%8lH", (long)addr);
 		break;
 	    case 'd':
 		db_printf("%11ld", (long)addr);
Index: sys/kern/subr_prf.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/subr_prf.c,v
retrieving revision 1.88
diff -u -r1.88 subr_prf.c
--- sys/kern/subr_prf.c	28 Sep 2002 21:34:31 -0000	1.88
+++ sys/kern/subr_prf.c	9 Oct 2002 21:49:08 -0000
@@ -662,7 +662,7 @@
 		case 'X':
 			base = 16;
 			goto handle_nosign;
-		case 'z':
+		case 'H':
 			base = 16;
 			if (sign)
 				goto handle_sign;

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




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