summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_prf.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-01-16 18:08:57 +0000
committerphk <phk@FreeBSD.org>1996-01-16 18:08:57 +0000
commit80fe9dce3306f953b4ea2a8704db23b570c99cf0 (patch)
tree75e5bffc3801337b3cea79ea4cbb90c041f5a0c3 /sys/kern/subr_prf.c
parent8f8e14b553e7a960954cd8a078a8e6451b3dfbd2 (diff)
downloadFreeBSD-src-80fe9dce3306f953b4ea2a8704db23b570c99cf0.zip
FreeBSD-src-80fe9dce3306f953b4ea2a8704db23b570c99cf0.tar.gz
Add support for %.{int|*}s
Diffstat (limited to 'sys/kern/subr_prf.c')
-rw-r--r--sys/kern/subr_prf.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 45531ea..1303f9b 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
- * $Id: subr_prf.c,v 1.20 1996/01/04 21:12:15 wollman Exp $
+ * $Id: subr_prf.c,v 1.21 1996/01/15 22:40:43 phk Exp $
*/
#include "opt_ddb.h"
@@ -426,7 +426,7 @@ kvprintf(char const *fmt, void (*func)(int, void*), void *arg, int radix, va_lis
char *p, *q, *d;
int ch, n;
u_long ul;
- int base, lflag, tmp, width, ladjust, sharpflag, neg, sign;
+ int base, lflag, tmp, width, ladjust, sharpflag, neg, sign, dot;
char padc;
int retval = 0;
@@ -450,7 +450,11 @@ kvprintf(char const *fmt, void (*func)(int, void*), void *arg, int radix, va_lis
sharpflag = 0;
neg = 0;
sign = 0;
+ dot = 0;
reswitch: switch (ch = *(u_char *)fmt++) {
+ case '.':
+ dot = 1;
+ goto reswitch;
case '#':
sharpflag = 1;
goto reswitch;
@@ -541,11 +545,16 @@ reswitch: switch (ch = *(u_char *)fmt++) {
p = va_arg(ap, char *);
if (p == NULL)
p = "(null)";
- width -= strlen (p);
+ if (!dot)
+ n = strlen (p);
+ else
+ for (n = 0; n < width && p[n]; n++)
+ continue;
+ width -= n;
if (!ladjust && width > 0)
while (width--)
PCHAR(padc);
- while (*p)
+ while (n--)
PCHAR(*p++);
if (ladjust && width > 0)
while (width--)
OpenPOWER on IntegriCloud