home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d0xx / d043 / cc.lha / Cc / manx / geterrs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-12-01  |  1.5 KB  |  94 lines

  1. /* Z editor options
  2. :ma=1
  3. :ts=6
  4. :bk=0
  5. :wm=0
  6. */
  7.  
  8. /*
  9.     This program, both executable and sources, are
  10.     
  11.                     Copyright 1986, Jay Ts
  12.  
  13.                     Box 890
  14.                     West Oneonta NY 13861
  15.  
  16.     You may copy, distribute, alter, and use them, but absolutely no
  17.     permission is granted to remove copyright notices from them or
  18.     distribute them, in whole or in part, as, or as part of, a
  19.     commercial product.
  20. */
  21.  
  22. #include "stdio.h"
  23.  
  24. #define MAXERRS 20
  25. #define FOUND_ERROR -1
  26.  
  27. extern char errfile[];
  28.  
  29. /*
  30.     The first few characters of the annoying lines that the
  31.     compiler/linker produces every time it runs.
  32.     These will be filtered out!
  33. */
  34.  
  35. char t[3][5] =
  36. {
  37.      {'A', 'z', 't', 'e', 'c'},
  38.      {'C', 'o', 'd', 'e', ':'},
  39.      {'A', 'b', 'o', 'r', 't'}
  40. };
  41.  
  42. FILE *fp, *fopen();
  43.  
  44. /* print error messages from Compiler's redirected output file */
  45.  
  46. int geterrs()
  47. {
  48.     int numerrs = 0, getline();
  49.     char s[128];
  50.  
  51.     if( (fp = fopen(errfile, "r")) == NULL)
  52.     {
  53.         printf("cc: open failed on error file %s\n", errfile);
  54.         return(1);
  55.     }
  56.  
  57.     while(getline(s)) if( ! fits(s))
  58.     {
  59.         printf("%s\n", s);
  60.         if(++numerrs > MAXERRS) break;
  61.     }
  62.  
  63.     if(fclose(fp) == -1) printf("can't close error file!\n");
  64.     return(numerrs);
  65. }
  66.  
  67. int getline(s)
  68. char *s;
  69. {
  70.     int i = 0, c;
  71.  
  72.     while((c = getc(fp)) != '\n' && c != EOF) s[i++] = c;
  73.     s[i] = '\0';
  74.     return(c == EOF ? 0 : 1);
  75. }
  76.  
  77. /*
  78.     check to see if line matches one of the messages
  79.     that the C compiler ALWAYS produces
  80. */
  81.  
  82. int fits(s)
  83. char *s;
  84. {
  85.     int i, j;
  86.  
  87.     for(i = 0; i < 3; i++)
  88.     {
  89.         for(j = 0; j < 5; j++) if(t[i][j] != s[j]) break;
  90.         if(j == 5) return(1);
  91.     }
  92.     return(0);
  93. }
  94.