// cleandis.c                       2016                          7/24/98

// Delete "continuation lines" in "dis" file produced by "ndisasm".

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

FILE *infile;
FILE *tempfile;

char infilename[20], instring[250], *optr, outfilename[20];

void main(int argc, char *argv[])
     {
     if(argc < 2)
          {
          printf("\n\n\t\aUSAGE: cleandis <filename>.\n\n");
          exit(1);
          }
          
     sprintf(infilename, "%s.dis", argv[1]);
     infile = fopen(infilename, "rt");
     if(!infile)
          {
          printf("\n\n\t\aCan't open %s!n\n", infilename);
          exit(1);
          }          
          
     sprintf(outfilename, "%s.tmp", argv[1]);
     tempfile = fopen(outfilename, "wt");
     if(!tempfile)
          {
          printf("\n\n\t\aCan't open %s!n\n", outfilename);
          fclose(infile);
          exit(1);
          }
          
     optr = instring + 4;

     while(!feof(infile))
          {
          fgets(instring, 250, infile);
          if(instring[0] == 32) continue;
          fputs(optr, tempfile);
          }
          
     fclose(infile);
     fclose(tempfile);
     
     sprintf(instring, "mv -f %s %s\n", outfilename, infilename);
     system(instring);
     }
          