Fixed a escape char const problem
git-svn-id: svn://svn.cc65.org/cc65/trunk@3235 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -250,9 +250,8 @@ static void SetTok (int tok)
|
|||||||
static int ParseChar (void)
|
static int ParseChar (void)
|
||||||
/* Parse a character. Converts escape chars into character codes. */
|
/* Parse a character. Converts escape chars into character codes. */
|
||||||
{
|
{
|
||||||
int I;
|
|
||||||
unsigned Val;
|
|
||||||
int C;
|
int C;
|
||||||
|
int HadError;
|
||||||
|
|
||||||
/* Check for escape chars */
|
/* Check for escape chars */
|
||||||
if (CurC == '\\') {
|
if (CurC == '\\') {
|
||||||
@@ -294,20 +293,23 @@ static int ParseChar (void)
|
|||||||
case 'x':
|
case 'x':
|
||||||
case 'X':
|
case 'X':
|
||||||
/* Hex character constant */
|
/* Hex character constant */
|
||||||
NextChar ();
|
if (!IsXDigit (NextC)) {
|
||||||
if (!IsXDigit (CurC)) {
|
|
||||||
Error ("\\x used with no following hex digits");
|
Error ("\\x used with no following hex digits");
|
||||||
C = ' ';
|
C = ' ';
|
||||||
}
|
} else {
|
||||||
I = 0;
|
HadError = 0;
|
||||||
C = 0;
|
C = 0;
|
||||||
while (IsXDigit (CurC)) {
|
while (IsXDigit (NextC)) {
|
||||||
if (++I <= 2) {
|
if ((C << 4) >= 256) {
|
||||||
C = (C << 4) | HexVal (CurC);
|
if (!HadError) {
|
||||||
} else if (I == 3) {
|
Error ("Hex character constant out of range");
|
||||||
Error ("Too many digits in hex character constant");
|
HadError = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
C = (C << 4) | HexVal (NextC);
|
||||||
|
}
|
||||||
|
NextChar ();
|
||||||
}
|
}
|
||||||
NextChar ();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
@@ -318,22 +320,24 @@ static int ParseChar (void)
|
|||||||
case '5':
|
case '5':
|
||||||
case '6':
|
case '6':
|
||||||
case '7':
|
case '7':
|
||||||
/* Octal constant ### FIXME: Eat all available octal chars! */
|
/* Octal constant */
|
||||||
I = 0;
|
HadError = 0;
|
||||||
Val = CurC - '0';
|
C = HexVal (CurC);
|
||||||
while (IsODigit (NextC) && ++I <= 3) {
|
while (IsODigit (NextC)) {
|
||||||
NextChar ();
|
if ((C << 3) >= 256) {
|
||||||
Val = (Val << 3) | (CurC - '0');
|
if (!HadError) {
|
||||||
}
|
Error ("Octal character constant out of range");
|
||||||
C = (int) Val;
|
HadError = 1;
|
||||||
if (Val >= 256) {
|
}
|
||||||
Error ("Character constant out of range: %u", Val);
|
} else {
|
||||||
C = ' ';
|
C = (C << 3) | HexVal (NextC);
|
||||||
}
|
}
|
||||||
break;
|
NextChar ();
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Error ("Illegal character constant");
|
Error ("Illegal character constant");
|
||||||
C = ' ';
|
C = ' ';
|
||||||
/* Try to do error recovery, otherwise the compiler will spit
|
/* Try to do error recovery, otherwise the compiler will spit
|
||||||
* out thousands of errors in this place and abort.
|
* out thousands of errors in this place and abort.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user