strip.c

MudOS_0.9.18/src/amiga/strip.c · 684 B

From the archive MudOS_0.9.18.tar.gz

Download the archive   « Back to the archive contents

#include <stdio.h>

main(int argc,char *argv[])
{
	FILE *FIn;
	unsigned int c;
	int mode=0;

	if (argc!=2) 
	{
		fprintf(stderr,"Error: no input filename given.\n");
		exit(0);
	}
	if (!(FIn=fopen(argv[1],"rb")))
	{
		fprintf(stderr,"Error opening %s\n",argv[1]);
		exit(0);
	}
	c=fgetc(FIn);
	while(!feof(FIn))
	{
		switch(mode)
		{
		case 0:
			if (c=='/')
				mode=1;
			else
				fputc(c,stdout);
			break;
		case 1:
			if (c=='*')
				mode=2;
			else
			{
				mode=0;
				fputc('/',stdout);
				fputc(c,stdout);
			}
			break;
		case 2:
			if (c=='*')
				mode=3;
			break;
		case 3:
			if (c=='/')
				mode=0;
			else
				mode=2;
			break;
		}
		c=fgetc(FIn);
	}
	fclose(FIn);
}

Site Stats

Snippets: 1791
Codebases: 571