scanner: Correct handling of \0101

The C language has this oddity that octal constants are 3 bytes so the sequence
"\0101" is two bytes and well defined by the langage. cc65 currently misparses
this as a 1 byte octal code. Add a count to fix this.

Signed-off-by: Alan Cox <etchedpixels@gmail.com>
This commit is contained in:
Alan Cox
2016-11-19 13:02:19 +00:00
parent 79e1b25c6c
commit 6ee1fd2a67

View File

@@ -267,6 +267,7 @@ static int ParseChar (void)
{ {
int C; int C;
int HadError; int HadError;
int Count;
/* Check for escape chars */ /* Check for escape chars */
if (CurC == '\\') { if (CurC == '\\') {
@@ -337,8 +338,9 @@ static int ParseChar (void)
case '7': case '7':
/* Octal constant */ /* Octal constant */
HadError = 0; HadError = 0;
Count = 1;
C = HexVal (CurC); C = HexVal (CurC);
while (IsODigit (NextC)) { while (IsODigit (NextC) && Count++ < 3) {
if ((C << 3) >= 256) { if ((C << 3) >= 256) {
if (!HadError) { if (!HadError) {
Error ("Octal character constant out of range"); Error ("Octal character constant out of range");