]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afs-snrpintf-support-percentp-for-ptrs-20090616
authorDerrick Brashear <shadow@dementia.org>
Tue, 16 Jun 2009 19:08:11 +0000 (19:08 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 16 Jun 2009 19:08:11 +0000 (19:08 +0000)
LICENSE IPL10

so we can portably log pointers

src/util/snprintf.c

index 6736f956dbda6197a8c31e937176a0d9b2f085df..5a5004a591f0be684f67a3bc9c93d32b5bf47022 100644 (file)
@@ -347,6 +347,26 @@ afs_vsnprintf(char *p, size_t avail, const char *fmt, va_list ap)
            len = strlen(x);
            break;
 
+       case 'p':               /* unsigned decimal integer */
+           UVAL = va_arg(ap, void *);
+
+           xbuf[0] = '0';
+           xbuf[1] = 'x';
+
+           if (!haveprec) {
+               if (zfill && !ljust)
+                   precision = width;
+               else
+                   precision = 1;
+           }
+           if (precision > MAXPREC)
+               precision = MAXPREC;
+
+           mkint(xbuf + 2, UVAL, 16, 0, precision);
+           x = xbuf + ((altform && UVAL) ? 0 : 2);
+           len = strlen(x);
+           break;
+
        case 'x':
        case 'X':               /* unsigned hexadecimal integer */
            if (lflag > 1)