diff options
| author | hkenken <hkenken@NetBSD.org> | 2014-03-22 02:51:44 +0000 |
|---|---|---|
| committer | hkenken <hkenken@NetBSD.org> | 2014-03-22 02:51:44 +0000 |
| commit | 5322f75b3a9f84f5f3e330b3c8b3e10fe2f613eb (patch) | |
| tree | 0598a81c93c97ae089d2ce1c1b905bc72fc59f4d /sys/lib | |
| parent | 45726fb8ce6485b22b69ea739105f332682c3dd8 (diff) | |
for LIBSA_PRINTF_WIDTH_SUPPORT,
Fix right and left-adjusting padding.
Diffstat (limited to 'sys/lib')
| -rw-r--r-- | sys/lib/libsa/subr_prf.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/lib/libsa/subr_prf.c b/sys/lib/libsa/subr_prf.c index e94a7a5356c..ffb60c9f02b 100644 --- a/sys/lib/libsa/subr_prf.c +++ b/sys/lib/libsa/subr_prf.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr_prf.c,v 1.23 2013/12/24 22:26:21 jakllsch Exp $ */ +/* $NetBSD: subr_prf.c,v 1.24 2014/03/22 02:51:44 hkenken Exp $ */ /*- * Copyright (c) 1993 @@ -79,7 +79,7 @@ const char hexdigits[16] = "0123456789abcdef"; #define ZEROPAD 0x40 #define NEGATIVE 0x80 #define KPRINTN(base) kprintn(put, ul, base, lflag, width) -#define RZERO() \ +#define LZERO() \ do { \ if ((lflag & (ZEROPAD|LADJUST)) == ZEROPAD) { \ while (width-- > 0) \ @@ -102,7 +102,7 @@ do { \ } while (/*CONSTCOND*/0) #else /* LIBSA_PRINTF_WIDTH_SUPPORT */ #define KPRINTN(base) kprintn(put, ul, base) -#define RZERO() /**/ +#define LZERO() /**/ #define RPAD() /**/ #define LPAD() /**/ #endif /* LIBSA_PRINTF_WIDTH_SUPPORT */ @@ -235,9 +235,9 @@ reswitch: #ifdef LIBSA_PRINTF_WIDTH_SUPPORT --width; #endif - RPAD(); - put(ch & 0xFF); LPAD(); + put(ch & 0xFF); + RPAD(); break; case 's': p = va_arg(ap, char *); @@ -246,10 +246,10 @@ reswitch: continue; width -= q - p; #endif - RPAD(); + LPAD(); while ((ch = (unsigned char)*p++)) put(ch); - LPAD(); + RPAD(); break; case 'd': ul = @@ -327,15 +327,15 @@ kprintn(void (*put)(int), UINTMAX_T ul, int base) else if (lflag & SPACE) *p++ = ' '; width -= p - buf; - if ((lflag & LADJUST) == 0) { + if (lflag & ZEROPAD) { while (p > q) put(*--p); } #endif - RPAD(); - RZERO(); + LPAD(); + LZERO(); do { put(*--p); } while (p > buf); - LPAD(); + RPAD(); } |
