Imported Upstream version 2.9.0
[debian/cc1111] / support / scripts / listerr.c
1 /*
2  * listerr.c - program to create the list of errors and warnings list from SDCCerr.c
3  *
4  * gcc -I ../../src listerr.c -o listerr
5  */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10
11 /* although this seems to be strange, this is the easiest way how to import the ErrTab without having to modify SDCCerr.c/h */
12 #include "SDCCerr.c"
13
14 // this is to make SDCCerr happy - simulate global SDCC variables
15 char *filename ;
16 int lineno ;
17 int fatalError ;
18
19
20 /* predefined names for errorlevels */
21 char *ErrTypeName[] = {
22   "ALL   ",
23   /** All warnings, including those considered 'reasonable to use,
24     on occasion, in clean programs' (man 3 gcc). */
25   "PEDANTIC",
26   /** 'informational' warnings */
27   "INFO  ",
28   /** Most warnings. */
29   "WARNING ",
30   /** Errors only. */
31   "ERROR   "
32   };
33
34
35 /* some simple internal variables */
36 int i;
37 char s[256];
38 char *p;
39
40 int main(int argc, char *argv[])
41 {
42   printf("Number  Type            Text\n"); /* output file header */
43   printf("------------------------------------------------------------------------------\n");
44   for (i = 0; i < MAX_ERROR_WARNING; i++)
45     {
46       if (ErrTab[i].errIndex == i)
47         {
48           strcpy(s, ErrTab[i].errText);
49           for (p = s; NULL != (p = strchr(s, '\n')); )
50             *p = ' '; /* replace all newlines by spaces */
51           printf("%3d     %-16.16s%s\n", ErrTab[i].errIndex, ErrTypeName[ErrTab[i].errType], s);
52         }
53     }
54
55   return 0;
56 }
57