nuisance block comments (nbc)
jeff at necntc.UUCP
jeff at necntc.UUCP
Fri Mar 13 03:06:17 AEST 1987
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 at necntc.nec.com]
Cheers,
---
Jeff Janock - NEC Electronics +1 617 655 8833
jeff at necntc.NEC.COM / jeff at 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 );
}
More information about the Comp.sources.unix
mailing list