From 0f26c1cc74a9347131c3d4821a42f32b5bc588a5 Mon Sep 17 00:00:00 2001 From: hkenken Date: Sat, 22 Mar 2014 02:51:44 +0000 Subject: [PATCH] for LIBSA_PRINTF_WIDTH_SUPPORT, Fix right and left-adjusting padding. --- sys/lib/libsa/subr_prf.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/lib/libsa/subr_prf.c b/sys/lib/libsa/subr_prf.c index e94a7a5356c2..ffb60c9f02b9 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(); }