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 <config.h>
7 
8 #include <stdio.h>
9 
10 #ifdef __cplusplus
11 extern "C" void exit(int);
12 #endif
13 
14 #define SPACE ' '
15 #define TAB '\t'
16 #define NL 10
17 
n_spaces(n)18 void n_spaces (n) /* n Spaces ausgeben */
19   int n;
20 {
21   while (!(n==0)) {
22     putchar(SPACE);
23     n--;
24   }
25 }
26 
main()27 int main ()
28 {
29   int c;
30   int spacecount;
31  zeilenanfang:
32   spacecount=0;
33  looking_for_space:
34   c = getchar(); if (c==EOF) { n_spaces(spacecount); goto eof; }
35   if (c==SPACE) {
36     spacecount++; goto looking_for_space;
37   }
38   if (c==TAB) {
39     do { spacecount++; } while (!((spacecount%8)==0));
40     goto looking_for_space;
41   }
42   /* c ist kein Space */
43   if (c=='#') { spacecount=0; }
44   n_spaces(spacecount);
45   /* Rest der Zeile unverändert übernehmen: */
46  rest:
47   putchar(c);
48   if (c==NL) goto zeilenanfang;
49   c = getchar(); if (c==EOF) { goto eof; }
50   goto rest;
51  eof: ;
52   if (ferror(stdin) || ferror(stdout) || fclose(stdout)) { exit(1); }
53   exit(0);
54 }
55 
56