Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!laguna.metaphor.COM!alex From: alex@laguna.metaphor.COM (Bob Alexander) Newsgroups: comp.lang.icon Subject: 1st bug in comment stripper Message-ID: <9009262122.AA01446@laguna.Metaphor.COM> Date: 26 Sep 90 21:22:59 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 26 I *knew* I should let this routine age for a couple of days before posting it! It couldn't handle "abc\"def". First bug fix (with a bit of vertical compactification, and other misc changes): procedure trimcomment(s1) # s2 # # Trim comments (and any trailing spaces) from Icon program text line. # local c,delim s1 ? { while tab(upto('"\'\\#')) do { case c := move(1) of { "#": if /delim then return trim(&subject[1:&pos - 1],' \t') "\\": if \delim then {="^" ; move(1)} # in case he used "\^"" default: delim := if \delim then (if delim == c then &null) else c } } } return trim(s1,' \t') end -- Bob Alexander Metaphor Computer Systems (415) 961-3600 x751 alex@metaphor.com ====^=== Mountain View, CA ...{uunet}!{decwrl,apple}!metaphor!alex