Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: nested comments Message-ID: <563@cresswell.quintus.UUCP> Date: 23 Jan 88 03:36:39 GMT References: <13423@pyramid.pyramid.com> <3460@ihlpf.ATT.COM> Organization: Quintus Computer Systems, Mountain View, CA Lines: 19 Summary: against If you have a pretty-printer (in 4BSD systems, see vgrind(1)) you want commented-out code to be formatted AS CODE, not as comments. I have a utility which displays files on a terminal with comments highlighted. I want unused code to look like code (I might want keywords underlined, for example). #if 0/#endif is exactly right for "commenting out". (It nests...) If you have a decent editor it is trivially easy to write a command which "comments out" a region even without nestable comments. The trick is this: insert */ at the end of the region while not at the beginning of the region move back one character if character is '/' replace it by " / " insert /* (we are now at the beginning). Any "/*xxx*/" comment inside will now be broken up as " / *xxx* / ". Inverting the operation is just as easy: replace each ' / ' in the region by '/'.