From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <002301c50e8a$56392af0$7c18dfd5@kilgore> From: "boyd, rounin" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> References: <41F879E200020C44@stateless1.tiscali.cz> Subject: Re: [9fans] 8c (pcc) bug?? Date: Wed, 9 Feb 2005 10:32:55 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-2"; reply-type=original Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4429898c-eace-11e9-9e20-41e7f4b1d025 this is one nasty bug. the problem is the // and /* comments are parsed twice: 1) in a #define 2) in an ordinary code block the assumption that /sys/src/cmd/cc/macbody makes [case #1] is that a #define consists of a: - name - optional list of args - list of names (possibly arguments) - line continuations - comments - characters should you have the misfortune to: #define S "//... or #define S "/*... you get: #define S " and you are in a "world of pain". to my mind it should be taught about strings, but this is somewhat non-trivial. well, maybe not. it needs to know about comments to skip arguments that maybe are hidden away in comment. ahh, this give me an idea. /sys/src/cmd/cc/lex.c [case 2] goes to some effort to lex up strings and pass them up to yacc. it uses esschar() which decodes chars & Runes in char and string constants, Rune by Rune. i'm not a language lawyer, nor do i have copies of the numerous standards, but do i do believe that: #define S "//foo" should give me: "//foo" hmm, yeah, i think i have a fix. -- MGRS 31U DQ 52572 12604