wm: teppich

Download patch

ref: e96c973f19c287ed575d5cc11dca00c048205f83
parent: dac7595daa2a23be27133fb13de340d4c2b7879d
author: mkf <mkf@cloud9p.org>
date: Mon Dec 4 11:08:59 EST 2023

printf: many changes!

use defcons instead of vga,
return number of formatted values (poorly),
made internal functions static

--- a/libc/printf.c
+++ b/libc/printf.c
@@ -1,31 +1,31 @@
 #include <u.h>
 #include <libc.h>
-//#include <vga.h>
+#include <cons.h>
 
-int
+static int
 print_char(int c)
 {
-	return vga_putc(c);
+	cons_putc(defcons, c);
+	return 1;
 }
 
-int
+static int
 print_str(char *str)
 {
-
-	vga_puts(str);
-
+	cons_write(defcons, str);
 	return strlen(str);
 }
 
-int
+static int
 print_digit(long num, int base)
 {
 	int count;
-	char* symbols = "0123456789abcdef";
+	char *d;
+	char *symbols = "0123456789abcdef";
 
 	if (num < 0)
 	{
-		vga_puts("-");
+		cons_write(defcons, "-");
 		return print_digit(-num, base) + 1;
 	}
 	else if (num < base)
@@ -40,7 +40,7 @@
 	
 }
 
-int
+static int
 print_format(char specifier, va_list ap)
 {
 	int count = 0;
@@ -59,7 +59,7 @@
 	case 'x':
 		count += print_digit((long)va_arg(ap, unsigned int), 16);
 	default:
-		count += vga_puts(specifier);
+		count += print_char(specifier);
 		break;
 	}
 
@@ -78,7 +78,7 @@
 		if (*format == '%') 
 			count += print_format(*(++format), ap);
 		else
-			count += vga_putc(*format);
+			count += print_char(*format);
 		format++;
 	}