Module Name:    src
Committed By:   hkenken
Date:           Sat Mar 22 02:51:44 UTC 2014

Modified Files:
        src/sys/lib/libsa: subr_prf.c

Log Message:
for LIBSA_PRINTF_WIDTH_SUPPORT,
Fix right and left-adjusting padding.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/lib/libsa/subr_prf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/lib/libsa/subr_prf.c
diff -u src/sys/lib/libsa/subr_prf.c:1.23 src/sys/lib/libsa/subr_prf.c:1.24
--- src/sys/lib/libsa/subr_prf.c:1.23	Tue Dec 24 22:26:21 2013
+++ src/sys/lib/libsa/subr_prf.c	Sat Mar 22 02:51:44 2014
@@ -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] = "0123456789ab
 #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, 
 	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();
 }

Reply via email to