fixes to scanner code.

This commit is contained in:
Vitor Santos Costa 2011-06-14 08:58:51 +01:00
parent ad58ff3ecc
commit 8991b5247a

View File

@ -804,6 +804,7 @@ extend_comment(int ch) {
LOCAL_CommentsBuffPos++; LOCAL_CommentsBuffPos++;
if (LOCAL_CommentsBuffPos == LOCAL_CommentsBuffLim-1) { if (LOCAL_CommentsBuffPos == LOCAL_CommentsBuffLim-1) {
LOCAL_CommentsBuff = (wchar_t *)realloc(LOCAL_CommentsBuff,sizeof(wchar_t)*(LOCAL_CommentsBuffLim+4096)); LOCAL_CommentsBuff = (wchar_t *)realloc(LOCAL_CommentsBuff,sizeof(wchar_t)*(LOCAL_CommentsBuffLim+4096));
LOCAL_CommentsBuffLim += 4096;
} }
} }
@ -812,6 +813,7 @@ close_comment(void) {
LOCAL_CommentsBuff[LOCAL_CommentsBuffPos] = '\0'; LOCAL_CommentsBuff[LOCAL_CommentsBuffPos] = '\0';
*LOCAL_CommentsNextChar = Yap_MkBlobWideStringTerm(LOCAL_CommentsBuff, LOCAL_CommentsBuffPos); *LOCAL_CommentsNextChar = Yap_MkBlobWideStringTerm(LOCAL_CommentsBuff, LOCAL_CommentsBuffPos);
free(LOCAL_CommentsBuff); free(LOCAL_CommentsBuff);
LOCAL_CommentsBuffLim = 0;
} }
static wchar_t * static wchar_t *
@ -1236,16 +1238,17 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp)
} }
if (chtype(ch) == EF) { if (chtype(ch) == EF) {
t->Tok = Ord(kind = eot_tok); t->Tok = Ord(kind = eot_tok);
} } else {
/* leave comments */ /* leave comments */
ch = getchr(inp_stream); ch = getchr(inp_stream);
if (t == l) { if (t == l) {
/* we found a comment before reading characters */ /* we found a comment before reading characters */
while (chtype(ch) == BS) { while (chtype(ch) == BS) {
ch = getchr(inp_stream); ch = getchr(inp_stream);
}
CHECK_SPACE();
*tposp = Yap_StreamPosition(inp_stream);
} }
CHECK_SPACE();
*tposp = Yap_StreamPosition(inp_stream);
} }
goto restart; goto restart;
} }
@ -1255,8 +1258,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp)
if (chtype(ch) == CC) if (chtype(ch) == CC)
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF); while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF);
t->Tok = Ord(kind = eot_tok); t->Tok = Ord(kind = eot_tok);
} } else {
else {
TokImage = ((AtomEntry *) ( Yap_PreAllocCodeSpace()))->StrOfAE; TokImage = ((AtomEntry *) ( Yap_PreAllocCodeSpace()))->StrOfAE;
charp = TokImage; charp = TokImage;
*charp++ = och; *charp++ = och;