Want a way to strip comments from a
Leo de Wit
leo at philmds.UUCP
Wed Mar 22 22:08:17 AEST 1989
In article <852 at lynx.zyx.SE> pem at spunk.zyx.SE (Per-Erik Martin) writes:
|Here's another example in C. It *is* a piece of cake (15 minutes work).
|The problem can be described with a simple automata which is easily coded
|in in C (with goto's, >yech<). I've tested it on most of the pathological
|examples given in this group and it seems to work.
[]
Appearances are deceptive, it won't handle trigraphs. For instance, try:
??' (trigraph for ^) and your code thinks it is in_char.
What's worse, on systems where char isn't signed and EOF == -1, it will
fail to see EOF (suggestion: don't use a char to compare against EOF).
Another cake that is hard to digest (let alone the goto's, it was baked
in only 15 minutes) 8-).
Leo.
P.S. What's the benefit of having a separate program strip off comments anyway?
More information about the Comp.lang.c
mailing list