[net.sources] nuisance block comments

jeff@necntc.UUCP (03/12/87)

I happened to make a comment about how annoying large
intro comments in source are to one of the programmers
here.   Here is what we came up with -

Here's to DEC and others for making programs like this worthwhile...

Do with this code as you see fit...
[send commment/whatever to rpk@necntc.nec.com]

Cheers,

---
Jeff Janock - NEC Electronics +1 617 655 8833
jeff@necntc.NEC.COM / jeff@necntc.UUCP
..!{mit-eddie, ames, decvax, pyramid, husc6, mirror}!necntc!jeff
                                    gatech!gt-eedsp!/
---
/*  nbc.c	v 1.0.00	11-mar-87	rpk
 *
 *  remove first block comment from a source file
 */

#include <stdio.h>

main( argc, argv)
int argc; char *argv[];
{
	FILE *fp;
	char ch, buffer[BUFSIZ];
	;
	if ( (fp = argc < 2 ? stdin : fopen( argv[1], "r" )) == NULL ) {
	    perror( argv[1] );
	    exit( 1 );
	    }
	while ( fgets( buffer, BUFSIZ, fp ) ) {
	    if ( strncmp( buffer, "/*******", 8 ) == 0 ) {
		while ( fgets( buffer, BUFSIZ, fp ) ) {
		    if ( strncmp( buffer, " *******", 8 ) == 0 )
			goto zip;
		    }
		}
	    else {
		fputs( buffer, stdout );
		}
	    }
zip:
	while ( (ch = getc( fp )) != EOF )
	    putchar( ch );

	exit( 0 );
}