summaryrefslogtreecommitdiff
path: root/sys/lib
diff options
context:
space:
mode:
authortsutsui <tsutsui@NetBSD.org>2014-08-30 14:24:02 +0000
committertsutsui <tsutsui@NetBSD.org>2014-08-30 14:24:02 +0000
commitbbcad93ef51ec78c28ef31268ebe36bf6b956611 (patch)
tree5f0e517456825822ea7e890b14d35c4dd200b124 /sys/lib
parentbd903b09d9c1faa92ad63c0a89e0cdc1f5196bda (diff)
Revert stupid and untested changes. There was no extra copy in the macros.
Christos, you should reread our commit guideline as a Core member.
Diffstat (limited to 'sys/lib')
-rw-r--r--sys/lib/libsa/subr_prf.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/sys/lib/libsa/subr_prf.c b/sys/lib/libsa/subr_prf.c
index 6734397ba74..d513951460d 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.26 2014/08/30 13:09:27 christos Exp $ */
+/* $NetBSD: subr_prf.c,v 1.27 2014/08/30 14:24:02 tsutsui Exp $ */
/*-
* Copyright (c) 1993
@@ -79,22 +79,30 @@ const char hexdigits[16] = "0123456789abcdef";
#define ZEROPAD 0x40
#define NEGATIVE 0x80
#define KPRINTN(base) kprintn(put, ul, base, lflag, width)
-#define LADJUSTPAD(c) \
+#define RADJUSTZEROPAD() \
+do { \
+ if ((lflag & (ZEROPAD|LADJUST)) == ZEROPAD) { \
+ while (width-- > 0) \
+ put('0'); \
+ } \
+} while (/*CONSTCOND*/0)
+#define LADJUSTPAD() \
do { \
if (lflag & LADJUST) { \
while (width-- > 0) \
- put(c); \
+ put(' '); \
} \
} while (/*CONSTCOND*/0)
-#define RADJUSTPAD(c) \
+#define RADJUSTPAD() \
do { \
if ((lflag & (ZEROPAD|LADJUST)) == 0) { \
while (width-- > 0) \
- put(c); \
+ put(' '); \
} \
} while (/*CONSTCOND*/0)
#else /* LIBSA_PRINTF_WIDTH_SUPPORT */
#define KPRINTN(base) kprintn(put, ul, base)
+#define RADJUSTZEROPAD() /**/
#define LADJUSTPAD() /**/
#define RADJUSTPAD() /**/
#endif /* LIBSA_PRINTF_WIDTH_SUPPORT */
@@ -227,9 +235,9 @@ reswitch:
#ifdef LIBSA_PRINTF_WIDTH_SUPPORT
--width;
#endif
- RADJUSTPAD(' ');
+ RADJUSTPAD();
put(ch & 0xFF);
- LADJUSTPAD(' ');
+ LADJUSTPAD();
break;
case 's':
p = va_arg(ap, char *);
@@ -238,10 +246,10 @@ reswitch:
continue;
width -= q - p;
#endif
- RADJUSTPAD(' ');
+ RADJUSTPAD();
while ((ch = (unsigned char)*p++))
put(ch);
- LADJUSTPAD(' ');
+ LADJUSTPAD();
break;
case 'd':
ul =
@@ -324,10 +332,10 @@ kprintn(void (*put)(int), UINTMAX_T ul, int base)
put(*--p);
}
#endif
- RADJUSTPAD(' ');
- RADJUSTPAD('0');
+ RADJUSTPAD();
+ RADJUSTZEROPAD();
do {
put(*--p);
} while (p > buf);
- LADJUSTPAD(' ');
+ LADJUSTPAD();
}