Massive patch for the first months work adding System FC to GHC #15
[ghc-hetmet.git] / utils / hstags / hstags-help.c
1 #include <stdio.h>
2 #include <string.h> /* for strlen */
3
4 /* typedef enum { False, True } Boolean; */
5
6 #define SKIP    /* Algol-68 lives */
7
8 main(argc,argv)
9 int argc;
10 char **argv;
11 {
12   unsigned line;
13   FILE *srcf;
14   int thisline = 0, lastline = 0, linestart = 0;
15   char linebuff[1024];
16
17   if(argc < 2)
18     {
19       fprintf(stderr,"usage: %s sourcefile",argv[0]);
20       exit(1);
21     }
22
23   if((srcf=fopen(argv[1],"r")) == NULL)
24     {
25       fprintf(stderr,"can't read %s\n",argv[1]);
26       exit(2);
27     }
28
29   *linebuff = '\0';
30
31   while(scanf("%u",&line)!=EOF)
32     {
33       if(line != lastline)
34         {
35           while(thisline < line && !feof(srcf))
36             {
37               linestart+=strlen(linebuff);
38               fgets(linebuff,1023,srcf);
39               thisline++;
40             }
41
42           if(thisline >= line)
43             {
44               char *chpos;
45               for(chpos = linebuff; *chpos != '=' && *chpos != '\n' && *chpos != '\0'; ++chpos)
46                 putchar(*chpos);
47
48               if(*chpos == '=')
49                 putchar('=');
50
51               printf("%c%d,%d\n",0177,line,linestart);
52             }
53           lastline = line;
54         }
55     }
56
57   fclose(srcf);
58   exit(0);
59 }