File: ccpaux.c

package info (click to toggle)
clisp 1:2.27-0.5
  • links: PTS
  • area: main
  • in suites: woody
  • size: 49,860 kB
  • ctags: 20,752
  • sloc: ansic: 123,781; lisp: 67,533; asm: 19,633; xml: 11,766; sh: 9,788; fortran: 8,307; makefile: 3,570; objc: 2,481; perl: 1,744; java: 341; yacc: 318; sed: 117
file content (53 lines) | stat: -rw-r--r-- 1,028 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* C-Programm-Präprozessor-Hilfe:
   Entfernt die Spaces und Tabs am Beginn jeder Zeile, die mit # anfängt.
   Bruno Haible 17.1.1991
*/

#include <stdio.h>

#ifdef __cplusplus
extern "C" void exit(int);
#endif

#define SPACE ' '
#define TAB '\t'
#define NL 10

void n_spaces (n) /* n Spaces ausgeben */
  int n;
{
  while (!(n==0)) {
    putchar(SPACE);
    n--;
  }
}

int main ()
{
  int c;
  int spacecount;
 zeilenanfang:
  spacecount=0;
 looking_for_space:
  c = getchar(); if (c==EOF) { n_spaces(spacecount); goto eof; }
  if (c==SPACE) {
    spacecount++; goto looking_for_space;
  }
  if (c==TAB) {
    do { spacecount++; } while (!((spacecount%8)==0));
    goto looking_for_space;
  }
  /* c ist kein Space */
  if (c=='#') { spacecount=0; }
  n_spaces(spacecount);
  /* Rest der Zeile unverändert übernehmen: */
 rest:
  putchar(c);
  if (c==NL) goto zeilenanfang;
  c = getchar(); if (c==EOF) { goto eof; }
  goto rest;
 eof: ;
  if (ferror(stdin) || fflush(stdout) || ferror(stdout)) { exit(1); }
  exit(0);
}