Re^4: Why nested comments not allowed?

Garrett A Wollman gwollman at jhunix.HCF.JHU.EDU
Thu Feb 22 01:16:49 AEST 1990


In article <13771 at cbnewsc.ATT.COM> dalenber at cbnewsc.ATT.COM (Russel Dalenberg) writes:
>I said: how do you handle the case where the above line of legal C is
>commented out.  If it's not commented out, there is no problem.
>
>The "usual" way to comment out such code would be:
>
>/*	printf("A comment is ended with */"); */
>
>Since quotes have *NO* significance within comments, the above comment
>ends with the first "*/" found; with *both* nested and non-nested comments!

I was one of those people in Dan Barrett's class.  My program has
a simple hook which can be enabled (call it "STRINGINCOMM") which
can handle such situations...AT A PRICE.  In *EITHER* style, you can
EITHER handle this situation correctly, or you can handle

/* ho hum, this is a quote chatacter -->" */

correctly.  Without knowing the programmer's intentions wrt comments,
it is *impossible* to handle both cases correctly in the same decommenter.

-GAWollman


-- 
"All societies are based on rules to protect pregnant women and children.
 . . . As racial survival is the only universal morality, no other bases
 is possible."           - Lazarus Long [RAH, _TEFL_]
---------------Hopkins doesn't *want* my opinions------------------------



More information about the Comp.lang.c mailing list