request for C comment stripper

Leo de Wit leo at philmds.UUCP
Tue Mar 21 04:32:04 AEST 1989


In article <5693 at ux.cs.man.ac.uk> ian at ux.cs.man.ac.uk (Ian Cottam) writes:
|
|I usually use a lex script for such things.  I didn't have one for
|C, but the following might do the trick.  N.B.  Not tested, not proven,
|no warranty!

	 [lex script omitted]

This will cover most ordinary cases; but not this one:

(startcom.h is either empty or contains a /* ).

main()
{
    puts("Testing 1");
#include "startcom.h"
    puts("Testing 2");
/*
    puts("Testing 3");
*/
}

The second puts should get commented out or not, depending on the
contents of the header file.
OK, I'll admit, it is a bit far-fetched 8-); it however proves once
again that it isn't exactly trivial to do the general case right.

	 Leo.



More information about the Comp.lang.c mailing list