for LIBSA_PRINTF_WIDTH_SUPPORT,

Fix right and left-adjusting padding.
This commit is contained in:
hkenken 2014-03-22 02:51:44 +00:00
parent 889cc98cdc
commit 0f26c1cc74
1 changed files with 11 additions and 11 deletions

View File

@ -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();
}