
/* util frob to prevent indent from bashing #asm statements */

#include <stdio.h>

FILE * fopen_carefully(name, mode)
char * name;
char * mode;
{
  FILE * f = fopen(name, mode);
  
  if (f) return(f);
  fprintf(stderr, "Can't open '%s'\n", name);
  exit(1);
}

main(argc, argv)
int argc;
char ** argv;
{
  FILE * inf;
  FILE * outf;
  char buf[256];
  char * p;
  int need_close = 0;

  if (argc < 3)
	{
	fprintf(stderr, "Try postdent <from> <to>\n");
	exit(1);
	}
  inf = fopen_carefully(argv[1], "r");
  outf = fopen_carefully(argv[2], "w");
  while (fgets(buf, 256, inf))
	{
	p = buf;
	if (!strncmp(buf, "/*#asm", 6))
		p += 2;
	if (!strncmp(buf, "#endasm", 7))
		need_close = 1;
	if (need_close && (!strncmp(buf, "*/\n", 3)))
		need_close = 0;
	    else
		fputs(p, outf);
	}
  fclose(inf);
  fclose(outf);
}

