* [9fans] 8c (pcc) bug??
@ 2005-02-09 6:49 tapique
2005-02-09 9:32 ` boyd, rounin
2005-02-09 13:02 ` Charles Forsyth
0 siblings, 2 replies; 6+ messages in thread
From: tapique @ 2005-02-09 6:49 UTC (permalink / raw)
To: 9fans
seems like 8c compiler doesn't like apostrophes in // comments:
// we don't have the value yet
doesn't work, while
// we dont have the value yet
works.
Tried with pcc, not directly 8c. Should not matter, however.
++pac
--------------------------
Posílejte SMS přes internet zdarma a bez reklamy. Pouze s TISCALI.
Více na http://www.tiscali.cz
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] 8c (pcc) bug??
2005-02-09 6:49 [9fans] 8c (pcc) bug?? tapique
@ 2005-02-09 9:32 ` boyd, rounin
2005-02-09 12:07 ` boyd, rounin
2005-02-09 13:02 ` Charles Forsyth
1 sibling, 1 reply; 6+ messages in thread
From: boyd, rounin @ 2005-02-09 9:32 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] 8c (pcc) bug??
2005-02-09 9:32 ` boyd, rounin
@ 2005-02-09 12:07 ` boyd, rounin
2005-02-09 13:29 ` C H Forsyth
2005-02-11 0:03 ` boyd, rounin
0 siblings, 2 replies; 6+ messages in thread
From: boyd, rounin @ 2005-02-09 12:07 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
i think if the following diff if applied to /sys/src/cmd/cc/macbody
it should fix this nasty bug. it's not amazingly well tested, but if
you're in a position to or are feeling brave, please do so
236a237,264
> if (c == '\'' || c == '"') {
> int e;
>
> base = allocn(base, len, 1);
> base[len++] = c;
> e = c;
>
> for (;;) {
> int p;
>
> p = c;
> if ((c = getc()) == '\n')
> break;
>
> base = allocn(base, len, 1);
> base[len++] = c;
>
> if (p == '\\' && c == e)
> continue;
>
> if (c == e) {
> c = getc();
> break;
> }
> }
>
> continue;
> }
--
MGRS 31U DQ 52572 12604
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] 8c (pcc) bug??
2005-02-09 6:49 [9fans] 8c (pcc) bug?? tapique
2005-02-09 9:32 ` boyd, rounin
@ 2005-02-09 13:02 ` Charles Forsyth
1 sibling, 0 replies; 6+ messages in thread
From: Charles Forsyth @ 2005-02-09 13:02 UTC (permalink / raw)
To: 9fans
>>Tried with pcc, not directly 8c. Should not matter, however.
you need to give -+ to pcc to have it (or rather underlying cpp) support c++ comments.
8c alone is fine
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] 8c (pcc) bug??
2005-02-09 12:07 ` boyd, rounin
@ 2005-02-09 13:29 ` C H Forsyth
2005-02-11 0:03 ` boyd, rounin
1 sibling, 0 replies; 6+ messages in thread
From: C H Forsyth @ 2005-02-09 13:29 UTC (permalink / raw)
To: 9fans
the reason i mentioned that i `thought' i had a fix
was that i wanted to think whether there was any
code that relied on a property of the existing implementation,
which i kept, somewhat messily, but boyd's tidier change doesn't.
the answer is ... /sys/include/libc.h:/^#define.*assert
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] 8c (pcc) bug??
2005-02-09 12:07 ` boyd, rounin
2005-02-09 13:29 ` C H Forsyth
@ 2005-02-11 0:03 ` boyd, rounin
1 sibling, 0 replies; 6+ messages in thread
From: boyd, rounin @ 2005-02-11 0:03 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
russ has pointed out that my fix has bugs, so don't apply it.
i'm gonna have another look "i'm sure it's down here somewhere".
--
MGRS 31U DQ 52572 12604
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-02-11 0:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-09 6:49 [9fans] 8c (pcc) bug?? tapique
2005-02-09 9:32 ` boyd, rounin
2005-02-09 12:07 ` boyd, rounin
2005-02-09 13:29 ` C H Forsyth
2005-02-11 0:03 ` boyd, rounin
2005-02-09 13:02 ` Charles Forsyth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).