xv6

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit b75c11b20edad4e507d5bc2455177de59a38ec9f
parent b74f4b57ae48719fca4fc621732b055b2debaf3e
Author: rsc <rsc>
Date:   Sun, 16 Jul 2006 16:00:03 +0000

add %s to cprintf for cons_puts

Diffstat:
Mconsole.c | 13++++++++++++-
Mulib.c | 10++++++++++
Muser.h | 1+
3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/console.c b/console.c @@ -105,7 +105,7 @@ printint(int xx, int base, int sgn) } /* - * print to the console. only understands %d and %x. + * print to the console. only understands %d, %x, %p, %s. */ void cprintf(char *fmt, ...) @@ -131,8 +131,19 @@ cprintf(char *fmt, ...) } else if(c == 'x' || c == 'p'){ printint(*ap, 16, 0); ap++; + } else if(c == 's'){ + char *s = (char*)*ap; + ap++; + while(*s != 0){ + real_cons_putc(*s); + s++; + } } else if(c == '%'){ real_cons_putc(c); + } else { + // Unknown % sequence. Print it to draw attention. + real_cons_putc('%'); + real_cons_putc(c); } state = 0; } diff --git a/ulib.c b/ulib.c @@ -16,3 +16,13 @@ puts1(char *s) return i; } +char* +strcpy(char *s, char *t) +{ + char *os; + + os = s; + while((*s++ = *t++) != 0) + ; + return os; +} diff --git a/user.h b/user.h @@ -13,3 +13,4 @@ int cons_puts(char*); int puts(char*); int puts1(char*); +char* strcpy(char*, char*);