small c: Send errors to stderr so we seen them under cc
authorAlan Cox <alan@linux.intel.com>
Wed, 15 Nov 2017 23:08:05 +0000 (23:08 +0000)
committerAlan Cox <alan@linux.intel.com>
Wed, 15 Nov 2017 23:08:05 +0000 (23:08 +0000)
Applications/SmallC/error.c

index 6cdb6c4..0bcbbca 100644 (file)
@@ -3,42 +3,32 @@
  *
  */
 
-#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
 #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++;
 }