From 29138fff8643194ec49cb79304d2a878d46c378b Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 16 Nov 2021 12:08:59 -0800 Subject: Feat: added heredocs Heredocs are simply strings written to tmp files. There was minimal bug testing here. Also, various bug fixes are included --- src/cmd/rc/io.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/cmd/rc/io.c') diff --git a/src/cmd/rc/io.c b/src/cmd/rc/io.c index 5152627..3e47036 100644 --- a/src/cmd/rc/io.c +++ b/src/cmd/rc/io.c @@ -88,7 +88,6 @@ refill(Io *io) return *io->b++&0xff; } - void flush(Io *io) { @@ -106,14 +105,13 @@ flush(Io *io) }else{ n = io->b-io->buf; if(n && write(io->fd, io->buf, n) < 0) - write(3, "write error\n", 12); + write(mapfd(3), "write error\n", 12); io->b = io->buf; io->e = io->buf + io->cap; } } -static void printchar(Io *io, int c) { @@ -123,7 +121,7 @@ printchar(Io *io, int c) *io->b++=c; } -void +static void printquote(Io *io, char *s) { printchar(io, '\''); @@ -142,7 +140,7 @@ printstr(Io *io, char *s) while(*s) printchar(io, *s++); } -void +static void printword(Io *io, char *s) { char *t; @@ -157,7 +155,7 @@ printword(Io *io, char *s) printstr(io, s); } -void +static void printptr(Io *io, void *v) { int n; @@ -170,8 +168,7 @@ printptr(Io *io, void *v) for(n = 28;n>=0;n-=4) printchar(io, "0123456789ABCDEF"[(p>>n)&0xF]); } -static -void +static void printint(Io *io, int n) { if(n<0){ @@ -192,8 +189,7 @@ printint(Io *io, int n) printchar(io, n%10+'0'); } -static -void +static void printoct(Io *io, unsigned n) { if(n>7) @@ -201,8 +197,7 @@ printoct(Io *io, unsigned n) printchar(io, (n&7)+'0'); } -static -void +static void printval(Io *io, Word *a) { if(a){ @@ -219,8 +214,7 @@ printval(Io *io, Word *a) #define C1 t->child[1] #define C2 t->child[2] -static -void +static void printtree(Io *io, Tree *t) { Tree *c, *nc; -- cgit v1.2.1