home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!caen!malgudi.oar.net!chemabs!jon
- From: jon@cas.org (Jon Vander Hill)
- Subject: Re: C comment parser?
- In-Reply-To: mcook@fendahl.dev.cdx.mot.com's message of Sun, 13 Dec 1992 00:54:54 GMT
- Message-ID: <JON.92Dec14132300@cas.org>
- Sender: usenet@cas.org
- Organization: Chemical Abstracts Service, Columbus, Ohio
- References: <1268@galileo.rtn.ca.boeing.com> <mcook.724208094@fendahl.dev.cdx.mot.com>
- Date: Mon, 14 Dec 1992 18:23:00 GMT
- Lines: 18
-
- >>>>> On Sun, 13 Dec 1992 00:54:54 GMT, mcook@fendahl.dev.cdx.mot.com (Michael Cook) said:
-
- > You can do it with index():
-
- > $pos = 0;
- > while (($pos = index($_, "/*", $pos)) >= 0)
- > {
- > $end = index($_, "*/", $pos + 2);
- > $end >= 0 || die "unterminated comment";
- > substr($_, $pos, $end - $pos + 2) = '';
- ^^
- > }
-
- For what it's worth, I believe the ANSI C standard says that a comments
- turn into blanks.
-
- Jon Vander Hill
- jon@cas.org
-