]> Devi Nivas Git - cs3210-lab0.git/commitdiff
add %s to cprintf for cons_puts
authorrsc <rsc>
Sun, 16 Jul 2006 16:00:03 +0000 (16:00 +0000)
committerrsc <rsc>
Sun, 16 Jul 2006 16:00:03 +0000 (16:00 +0000)
console.c
ulib.c
user.h

index eb394f12b0f684c1da8e1421667474871a8253d0..28ef587d73713d3b44a7fc2c2d861f8caaab6c60 100644 (file)
--- 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
index 97afc8c2c6560e39178bdb1492642b543b1c3900..d7e8934a0338ca907de25cff7dc36e299e16caa2 100644 (file)
--- 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
index 7571767ff77d24561a4f2d528c0b94cb6239d6ac..16664cabf9132a6a86996795b2a8d763a7a4098a 100644 (file)
--- a/user.h
+++ b/user.h
@@ -13,3 +13,4 @@ int cons_puts(char*);
 
 int puts(char*);
 int puts1(char*);
+char* strcpy(char*, char*);