summaryrefslogtreecommitdiff
path: root/support/tspell/putback.c
blob: d551304b8119150a204f9db04a9dac96ab0bbb2d (plain)
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
% Save file as: PUTBACK.C              Source: FILESERV@SHSU.BITNET  
#include <stdio.h>
main(argc,argv)
int argc,*argv[];
{char ch;
 int check,check1;
 FILE *fp1,*fp2,*fp3,*fopen();
 if(argc<4)
{printf("useage: putback inputfile  spellcheckedfile  outputfile");
exit(1);
}
 check1=0;
 fp1=fopen(argv[1],"r");
 fp2=fopen(argv[2],"r");
 fp3=fopen(argv[3],"w");
 if(fp1==NULL){printf("putback:input file not found");exit(1);}
 if(fp2==NULL){printf("putback:spell-checked file not found");exit(1);}
 if(fp3==NULL){printf("putback:output file cannot be created");exit(1);}
 for(ch=fgetc(fp2);ch!=EOF;ch=fgetc(fp2))
{ 
  switch(ch)
  {case '\\': 
              fputc(ch,fp3);
             check=1;
             if(check1!=1)
             for(ch=fgetc(fp1);ch!='\\';ch=fgetc(fp1));
             else
              check1=0;
              
             while(check!=0)
             {ch=fgetc(fp1);
              switch(ch)
              {case ' ':check=0; break;
               case '{':check=0; break;
               case '\n':check=0;break;
               case '\t':check=0;break;
               case '\\':check=0;check1=1;break;
               case EOF:break;
               default :fputc(ch,fp3);
              }
             }
             break;
   default:fputc(ch,fp3);
  } 
}
  
}