Fixed off-by-one error in LexGetToken()
git-svn-id: http://picoc.googlecode.com/svn/trunk@59 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
11fd7f0f16
commit
d95e7debf8
13
lex.c
13
lex.c
|
@ -302,6 +302,7 @@ void *LexTokenise(struct LexState *Lexer)
|
||||||
do
|
do
|
||||||
{ /* store the token at the end of the stack area */
|
{ /* store the token at the end of the stack area */
|
||||||
Token = LexScanGetToken(Lexer, &GotValue);
|
Token = LexScanGetToken(Lexer, &GotValue);
|
||||||
|
printf("Token: %02x\n", Token);
|
||||||
*(char *)TokenSpace = Token;
|
*(char *)TokenSpace = Token;
|
||||||
TokenSpace++;
|
TokenSpace++;
|
||||||
MemUsed++;
|
MemUsed++;
|
||||||
|
@ -326,7 +327,14 @@ void *LexTokenise(struct LexState *Lexer)
|
||||||
LexFail(Lexer, "out of memory while lexing");
|
LexFail(Lexer, "out of memory while lexing");
|
||||||
|
|
||||||
HeapMem = HeapAlloc(MemUsed);
|
HeapMem = HeapAlloc(MemUsed);
|
||||||
memcpy(HeapMem, HeapStackGetFreeSpace(&MemAvailable), MemUsed);
|
memcpy(HeapMem, HeapStackGetFreeSpace(&MemAvailable), MemUsed);
|
||||||
|
{
|
||||||
|
int Count;
|
||||||
|
for (Count = 0; Count < MemUsed; Count++)
|
||||||
|
printf("%02x ", *(unsigned char *)(HeapMem+Count));
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
return HeapMem;
|
return HeapMem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +385,7 @@ enum LexToken LexGetToken(struct ParseState *Parser, struct Value **Value, int I
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(LexValue.Val, Parser->Pos, ValueSize);
|
memcpy(LexValue.Val, Parser->Pos+1, ValueSize);
|
||||||
LexValue.ValOnHeap = FALSE;
|
LexValue.ValOnHeap = FALSE;
|
||||||
LexValue.ValOnStack = FALSE;
|
LexValue.ValOnStack = FALSE;
|
||||||
*Value = &LexValue;
|
*Value = &LexValue;
|
||||||
|
@ -392,6 +400,7 @@ enum LexToken LexGetToken(struct ParseState *Parser, struct Value **Value, int I
|
||||||
Parser->Pos++;
|
Parser->Pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("Got token=%02x inc=%d\n", Token, IncPos);
|
||||||
return Token;
|
return Token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue