
/*
	Strip semicolon comments from a text file.
*/

main(argc,argv)
int argc;
char **argv;
{
char *cp,buff[256];
int in,out;

	allmem();
	fastfile(1);
	printf("Assembly source file scruncher\r\n");
	printf("Tom Jennings, Fido Software\r\n");
	printf("Box 77731, San Francisco CA 94107, USA\r\n");
	printf("(k) All Rites Reversed\r\n");

	strcpy(buff,argv[1]);
	strcat(buff,".do");
	in= open(buff,0);
	if (in == -1) {
		printf("\r\nFile missing. Try this:\r\n\r\n");
		printf("SCRUNCH filename\r\n");
		printf("Scrunch strips all comments and blank lines from a file\r\n");
		printf("\"filename.DO\" and puts the result into file \"filename.OUT\"\r\n");
		printf("The original .DO file is untouched.\r\n");
		exit(1);
	}
	strcpy(buff,argv[1]);
	strcat(buff,".out");
	out= creat(buff,1);

	while (rline(in,buff,sizeof(buff))) {
		for (cp= buff; *cp; ++cp) {
			if (*cp == ';') {		/* if we find a ; */
hack:				*cp--= 0;		/* delete it */
				if (cp <= buff) break;	/* (start of line) */
				if ((*cp == ' ') || (*cp == 9)) {
					goto hack;
				}
				break;
			}
		}
		if (*buff) {
			write(out,buff,strlen(buff));
			write(out,"\r\n",2);
		}
	}
	close(in); close(out);
}

