From 8b4ce96eff7ea7c6f1fe2b013cbdea4be13b8520 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 15 Nov 2017 23:08:05 +0000 Subject: [PATCH] small c: Send errors to stderr so we seen them under cc --- Applications/SmallC/error.c | 42 ++++++++++++++----------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/Applications/SmallC/error.c b/Applications/SmallC/error.c index 6cdb6c4e..0bcbbca5 100644 --- a/Applications/SmallC/error.c +++ b/Applications/SmallC/error.c @@ -3,42 +3,32 @@ * */ -#include +#include +#include #include "defs.h" #include "data.h" -void error(char *ptr) +void errchar(char c) { - int tempfile; - - tempfile = output; - output = 1; - doerror(ptr); - output = tempfile; - doerror(ptr); - errcnt++; + write(2, &c, 1); } -void doerror(char *ptr) +void error(char *ptr) { - int k; - gen_comment (); - output_string (line); - newline (); - gen_comment (); - k = 0; + int k = 0;; + + write(2, line, strlen(line)); + errchar('\n'); while (k < lptr) { if (line[k] == 9) - print_tab (); + errchar('\t'); else - output_byte (' '); + errchar(' '); k++; } - output_byte ('^'); - newline (); - gen_comment (); - output_string ("****** "); - output_string (ptr); - output_string (" ******"); - newline (); + errchar('^'); + errchar('\n'); + write(2, ptr, strlen(ptr)); + errchar('\n'); + errcnt++; } -- 2.34.1