home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume12 / cake / part04 / Aux / refs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-10-14  |  828 b   |  63 lines

  1. /*
  2. **    A program to filter out references.
  3. */
  4.  
  5. #include    <stdio.h>
  6. #include    "std.h"
  7.  
  8. int    more = TRUE;
  9.  
  10. main()
  11. {
  12.     extern    char    yytext[];
  13.     reg    FILE    *out;
  14.     reg    int    code;
  15.     reg    bool    init, ignore;
  16.  
  17.     out = popen("sed -e 's/[     ]*$//'", "w");
  18.  
  19.     code = yylex();
  20.     while (more)
  21.     {
  22.         if (code == 2)
  23.         {
  24.             ignore = FALSE;
  25.             init = TRUE;
  26.             code = yylex();
  27.             while (more && code != -2)
  28.             {
  29.                 if (streq(yytext, "{"))
  30.                     ignore = TRUE;
  31.                 or (streq(yytext, "}"))
  32.                     ignore = FALSE;
  33.                 or (ignore)
  34.                     ;
  35.                 or (streq(yytext, ","))
  36.                 {
  37.                     putc('\n', out);
  38.                     init = TRUE;
  39.                 }
  40.                 or (streq(yytext, " "))
  41.                 {
  42.                     if (! init)
  43.                         putc(' ', out);
  44.                 }
  45.                 else
  46.                 {
  47.                     fprintf(out, "%s", yytext);
  48.                     init = FALSE;
  49.                 }
  50.  
  51.                 code = yylex();
  52.             }
  53.  
  54.             putc('\n', out);
  55.         }
  56.  
  57.         code = yylex();
  58.     }
  59.  
  60.     pclose(out);
  61.     exit(0);
  62. }
  63.