home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / utils / ccpaux.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-23  |  1.0 KB  |  42 lines

  1. /* C-Programm-PrΣprozessor-Hilfe:
  2.    Entfernt die Spaces und Tabs am Beginn jeder Zeile, die mit # anfΣngt.
  3.    Bruno Haible 17.1.1991
  4. */
  5.  
  6. #include <stdio.h>
  7.  
  8. #define SPACE ' '
  9. #define TAB '\t'
  10. #define NL 10
  11.  
  12. void n_spaces (n) /* n Spaces ausgeben */
  13.   int n;
  14.   { while (!(n==0)) { putchar(SPACE); n--; } }
  15.  
  16. main ()
  17.   { int c;
  18.     int spacecount;
  19.     zeilenanfang:
  20.       spacecount=0;
  21.       looking_for_space:
  22.         c = getchar(); if (c==EOF) { n_spaces(spacecount); goto eof; }
  23.         if (c==SPACE) { spacecount++; goto looking_for_space; }
  24.         if (c==TAB)
  25.           { do { spacecount++; } while (!((spacecount%8)==0));
  26.             goto looking_for_space;
  27.           }
  28.       /* c ist kein Space */
  29.       if (c=='#') { spacecount=0; }
  30.       n_spaces(spacecount);
  31.       /* Rest der Zeile unverΣndert ⁿbernehmen: */
  32.       rest:
  33.         putchar(c);
  34.         if (c==NL) goto zeilenanfang;
  35.         c = getchar(); if (c==EOF) { goto eof; }
  36.         goto rest;
  37.     eof: ;
  38.     if (ferror(stdin) || ferror(stdout)) { exit(1); }
  39.     exit(0);
  40.   }
  41.  
  42.