| > ---------- Forwarded message ----------
> From: Rolf
>
> I have some comments after trying Csound 3.493.
> *The /* */ comment has not worked for me with more
> than one line( neither on mac nor windows). The text between is
> debugged.
...and any text following the end-of-comment sign on the same
line will be missed. Eg, on
iamp = /*32000*/ 15000
the 15000 won't be seen.
I have an almost-fix for all this. It is "almost" since the line
where the comment begins will be tagged with the orch source file
line number of the comment termination line.
This leads to bad behaviour with orchestra error messages, which will
show incorrect line number for that line of orch code.
This is because there is a global variable which holds current line
number, and we need to muck about with that to do the fix. To get
around this, I believe some larger rewrite is needed.
I have run it with a test orch on Win95, which is included below.
There is a similar bug in backslash line-continuation, but that one
requires a deeper incision. It looks like John has begun doing
something to fix all these problems (the written but never read
array srclin, indexed by srccnt, in rdorch.c).
I think a lot of the code in Rdorch.C ought rather to be rewritten
from scratch to separate the new linenum-warping preprocessor-type
features from the old orch parsing, but I'm not doing it, so
shouldn't nag.
Anyway here goes, if anyone wants to try it.
re
(Longest line is 90+ chars, somewhere else in code)
The C-comment code is in Rdorch.c, splitline(),
lines 561-567:
if (c == '/' && *lp == '*') { /* C Style comments */
char *ll = strstr(++lp, "*/");
int nxtline;
if (ll == NULL) synterrp(lp-2, "Unmatched comment");
lp = ll+2;
break;
}
To fix the present bugs (and introduce a minor new one), substitute this:
if (c == '/' && *lp == '*') { /* C Style comments */
char *ll = strstr(++lp, "*/");
int nxtline;
/* v 3.48 code:
if (ll == NULL) synterrp(lp-2, "Unmatched comment");
lp = ll+2;
break; */
/* Fix for multi-line comments (re Dec 22, 1998) */
if(ll == NULL) {
synterrp(lp-2, "Unmatched comment");
while(linadr[++curline] != NULL) ; /* Skip to last line */
curline--;
break; /* After break we jump to nxtlin, then orch read terminates */
}
nxtline = curline;
while( linadr[++nxtline] <= ll ) ; /* Move to end-of-comment line */
curline = nxtline-1; /* A problem: Now errors on line where multi-line */
lp = ll+2; /* comment began will show wrong line number */
continue; /* not break, else miss orch code after end-of-comment sign */
/* End of re changes */
}
########## End of C code #############
DEMONSTRATION OF PROBLEMS -- ORC which should be legal
with proper C-style comment parsing!
; ORCHESTRA FILE -- Comments.orc
sr = 22050
kr = 2205
ksmps = 10
nchnls = 2
; This instr only tests various comment situations
instr 1
iamp = /* 30000 */ 15000
ibasfrq = p4
; /* This comment should be hidden by semicolon
a1 oscil iamp, ibasfrq, 1 /*
This comment covers the newline chars,
so the lines will be concatenated
*/ , 0.5 ;So here we have the optional iphs arg of oscil
/* This should be ok since it's preceded by a newline
*/ a2 oscil iamp, ibasfrq*2.5, 1
a3 oscil iamp, ibasfrq, 1 /*
Another one hiding some newlines
But the a4 oscil below should be parsed on new line
; */
a4 oscil iamp, ibasfrq / 2, 1
/* A multiline one which should still find eoc sign
notlegal = 2*5/ iamp ; */
/* /* This is single-line: The terminator terminates all */
a4 oscil iamp, ibasfrq*3.3, 1 ; We should hear this */
/* *;/ * /
* /
another stupid test ends here */
; Output should be: Left: 100+250 Hz; Right: 50+330 Hz
outs a1+a2, a3+a4
; Demonstration of bug in the bugfix
; a3 oscil notlegal, ibasfrq / 2, 1 /*
/*If the semicolon is removed from the line above, the error
messages will show wrong line number. The actual line number
is 42, but shows as 46 with my buggy "bugfix"!
*/
; /* If semicolon is removed, this one is unmatched
endin
; ######### End Comments.orc ########
; SCORE FILE -- Comments.sco
f1 0 8192 10 1
i1 0 2 100
|