/*----------------------------------------------------------------------- * File Name: cvcom.c * * Author: Jonathan E. Flamm * Date: 6/4/94 * Description: Converts C++ style comments to C style comments. * Reads from Stdin and writes to Stdout *-----------------------------------------------------------------------*/ #include #define True 1 #define False 0 main( int argc, char **argv ) { int c; int lastChar = 0; int inComment = False; if (argc != 1) { fprintf(stderr, "\nUsage: %s < infile > outfile\n", *argv); fprintf(stderr, "Converts C++ style comments to C\n"); exit(1); } while ( (c = getchar()) != EOF ) { if (inComment) { if ( (c == '\r') || (c == '\n') ) { puts(" */"); inComment = False; putchar(c); } else putchar(c); } else if (c == '/') { if (lastChar == '/') { putchar('*'); inComment = True; } else { putchar(c); } } else putchar(c); lastChar = c; } }