#1 string literals are not handled properly

open
nobody
None
5
2004-08-19
2004-08-19
Anonymous
No

In the class com.objfac.prebop.Expression.java, the
method makeLit(int) has a bug.
The position 'fPos' has to be incremented if it points
to a quote!

private Term makeLit(int c) throws PreprocessorError {
int quote = c;
StringBuffer buf = new StringBuffer();
while (fPos < fEnd && fBuf[fPos] != quote) {
buf.append((char)fBuf[fPos++]);
}
if (fPos == fEnd) {
return error("Unterminated string in expression ",
fBuf);
// added code starts here
} else if (fBuf[fPos] == quote) {
fPos++;
}
return new StringConstant(buf.toString());
}

Regards,
Pierce
ps.shah@datacomm.ch

Discussion

  • Expression.java

     
    Attachments
  • Logged In: NO

    It is possible to get around this by declaring all of your
    string constants as variables that have the same name as the
    value (e.g. <var name="Handset" value="Handset">) then you
    can use them as if they were string literals and it will work

    $if Handsets == Handsets $ (or whatever)