% Save file as: PUTBACK.C              Source: [email protected]
#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);
 }
}

}