From 8682553498d32d3c18dea41c598ab40de18404a3 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 16 Jul 2026 07:30:34 +0200 Subject: tools: wc, head, and an argc/argv demo (args) + libc.c helpers - c/libc.c: shared C helpers linked into every program - putu (print decimal), atou (parse decimal), argv_parse (tokenize getargs() into argc/argv). - wc: count lines/words/chars of stdin. head [n]: first n lines (drains rest to EOF). args: argc/argv demo. - pid now uses libc putu; build.sh links libc.c; Makefile CBLOBS + libc dep. - README: document the new tools + argv_parse. - verified: 'args one two three' -> argc=3/argv[..]; wc '2 3 16'; head 2. --- c/pid.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'c/pid.c') diff --git a/c/pid.c b/c/pid.c index a282a89..9e4e792 100644 --- a/c/pid.c +++ b/c/pid.c @@ -1,9 +1,2 @@ #include "gbos.h" -/* print an unsigned byte as decimal (no runtime division: subtract-based) */ -static void putu(unsigned char n) { - char buf[3]; unsigned char i = 0; - if (n == 0) { putc('0'); return; } - while (n) { buf[i++] = '0' + (n % 10); n = n / 10; } - while (i) putc(buf[--i]); -} void main(void) { putu(getpid()); nl(); } -- cgit v1.3.1-sl0p