cannot hold the lock while getting a char: someone else may be trying to add to the stream.
This commit is contained in:
parent
2d425fb7b4
commit
52c019ec54
16
C/scanner.c
16
C/scanner.c
@ -791,7 +791,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
ScannerExtraBlocks = NULL;
|
ScannerExtraBlocks = NULL;
|
||||||
l = NULL;
|
l = NULL;
|
||||||
p = NULL; /* Just to make lint happy */
|
p = NULL; /* Just to make lint happy */
|
||||||
LOCK(Stream[inp_stream].streamlock);
|
|
||||||
ch = Nxtch(inp_stream);
|
ch = Nxtch(inp_stream);
|
||||||
while (chtype(ch) == BS) {
|
while (chtype(ch) == BS) {
|
||||||
ch = Nxtch(inp_stream);
|
ch = Nxtch(inp_stream);
|
||||||
@ -813,7 +812,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
if (p)
|
if (p)
|
||||||
p->Tok = Ord(kind = eot_tok);
|
p->Tok = Ord(kind = eot_tok);
|
||||||
/* serious error now */
|
/* serious error now */
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
if (!l)
|
if (!l)
|
||||||
@ -867,7 +865,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
if (p)
|
if (p)
|
||||||
p->Tok = Ord(kind = eot_tok);
|
p->Tok = Ord(kind = eot_tok);
|
||||||
/* serious error now */
|
/* serious error now */
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
add_ch_to_buff(ch);
|
add_ch_to_buff(ch);
|
||||||
@ -894,7 +891,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
if (p)
|
if (p)
|
||||||
t->Tok = Ord(kind = eot_tok);
|
t->Tok = Ord(kind = eot_tok);
|
||||||
/* serious error now */
|
/* serious error now */
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
t->TokInfo = Unsigned(ae);
|
t->TokInfo = Unsigned(ae);
|
||||||
@ -917,7 +913,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
|
|
||||||
cherr = 0;
|
cherr = 0;
|
||||||
if (!(ptr = AllocScannerMemory(4096))) {
|
if (!(ptr = AllocScannerMemory(4096))) {
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
Yap_ErrorMessage = "Trail Overflow";
|
Yap_ErrorMessage = "Trail Overflow";
|
||||||
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
|
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
|
||||||
if (p)
|
if (p)
|
||||||
@ -926,7 +921,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
if (ASP-H < 1024) {
|
if (ASP-H < 1024) {
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
Yap_ErrorMessage = "Stack Overflow";
|
Yap_ErrorMessage = "Stack Overflow";
|
||||||
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
|
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
|
||||||
Yap_Error_Size = 0L;
|
Yap_Error_Size = 0L;
|
||||||
@ -936,7 +930,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
if ((t->TokInfo = get_num(&cha,&cherr,inp_stream,Nxtch,QuotedNxtch,ptr,4096,1)) == 0L) {
|
if ((t->TokInfo = get_num(&cha,&cherr,inp_stream,Nxtch,QuotedNxtch,ptr,4096,1)) == 0L) {
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
if (p)
|
if (p)
|
||||||
p->Tok = Ord(kind = eot_tok);
|
p->Tok = Ord(kind = eot_tok);
|
||||||
/* serious error now */
|
/* serious error now */
|
||||||
@ -950,7 +943,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
t->TokPos = GetCurInpPos(inp_stream);
|
t->TokPos = GetCurInpPos(inp_stream);
|
||||||
e = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
e = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
Yap_ErrorMessage = "Trail Overflow";
|
Yap_ErrorMessage = "Trail Overflow";
|
||||||
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
|
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
|
||||||
if (p)
|
if (p)
|
||||||
@ -980,7 +972,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
t->TokPos = GetCurInpPos(inp_stream);
|
t->TokPos = GetCurInpPos(inp_stream);
|
||||||
e2 = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
e2 = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
||||||
if (e2 == NULL) {
|
if (e2 == NULL) {
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
Yap_ErrorMessage = "Trail Overflow";
|
Yap_ErrorMessage = "Trail Overflow";
|
||||||
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
|
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
|
||||||
if (p)
|
if (p)
|
||||||
@ -1012,7 +1003,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
t->TokPos = GetCurInpPos(inp_stream);
|
t->TokPos = GetCurInpPos(inp_stream);
|
||||||
e2 = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
e2 = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
||||||
if (e2 == NULL) {
|
if (e2 == NULL) {
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
Yap_ErrorMessage = "Trail Overflow";
|
Yap_ErrorMessage = "Trail Overflow";
|
||||||
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
|
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
|
||||||
t->Tok = Ord(kind = eot_tok);
|
t->Tok = Ord(kind = eot_tok);
|
||||||
@ -1078,7 +1068,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
}
|
}
|
||||||
++len;
|
++len;
|
||||||
if (charp > (char *)AuxSp - 1024) {
|
if (charp > (char *)AuxSp - 1024) {
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
/* Not enough space to read in the string. */
|
/* Not enough space to read in the string. */
|
||||||
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
|
Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
|
||||||
Yap_ErrorMessage = "not enough space to read in string or quoted atom";
|
Yap_ErrorMessage = "not enough space to read in string or quoted atom";
|
||||||
@ -1100,7 +1089,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
mp = AllocScannerMemory(len + 1);
|
mp = AllocScannerMemory(len + 1);
|
||||||
}
|
}
|
||||||
if (mp == NULL) {
|
if (mp == NULL) {
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
Yap_ErrorMessage = "not enough heap space to read in string or quoted atom";
|
Yap_ErrorMessage = "not enough heap space to read in string or quoted atom";
|
||||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||||
t->Tok = Ord(kind = eot_tok);
|
t->Tok = Ord(kind = eot_tok);
|
||||||
@ -1129,7 +1117,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
if (p)
|
if (p)
|
||||||
t->Tok = Ord(kind = eot_tok);
|
t->Tok = Ord(kind = eot_tok);
|
||||||
/* serious error now */
|
/* serious error now */
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||||
@ -1182,7 +1169,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
if (p)
|
if (p)
|
||||||
t->Tok = Ord(kind = eot_tok);
|
t->Tok = Ord(kind = eot_tok);
|
||||||
/* serious error now */
|
/* serious error now */
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||||
@ -1253,7 +1239,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
/* insert an error token to inform the system of what happened */
|
/* insert an error token to inform the system of what happened */
|
||||||
TokEntry *e = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
TokEntry *e = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
Yap_ErrorMessage = "Trail Overflow";
|
Yap_ErrorMessage = "Trail Overflow";
|
||||||
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
|
Yap_Error_TYPE = OUT_OF_TRAIL_ERROR;
|
||||||
p->Tok = Ord(kind = eot_tok);
|
p->Tok = Ord(kind = eot_tok);
|
||||||
@ -1269,7 +1254,6 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
p = e;
|
p = e;
|
||||||
}
|
}
|
||||||
} while (kind != eot_tok);
|
} while (kind != eot_tok);
|
||||||
UNLOCK(Stream[inp_stream].streamlock);
|
|
||||||
return (l);
|
return (l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user