bug in EOF processing when doing read.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@885 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2003-10-06 14:16:23 +00:00
parent 32301f0060
commit 2db3829b82
3 changed files with 23 additions and 15 deletions

View File

@ -1580,7 +1580,11 @@ Yap_Error (yap_error_number type, Term where, char *format,...)
}
if (type != PURE_ABORT) {
/* This is used by some complex procedures to detect there was an error */
if (IsAtomTerm(nt[0])) {
Yap_ErrorMessage = RepAtom(AtomOfTerm(nt[0]))->StrOfAE;
} else {
Yap_ErrorMessage = RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE;
}
}
switch (type) {
case OUT_OF_HEAP_ERROR:

View File

@ -2983,8 +2983,11 @@ do_read(int inp_stream)
/* preserve value of H after scanning: otherwise we may lose strings
and floats */
old_H = H;
if ((Stream[inp_stream].status & Eof_Stream_f)
&& !Yap_eot_before_eof) {
if (Stream[inp_stream].status & Eof_Stream_f) {
if (Yap_eot_before_eof) {
/* next read should give out an end of file */
Stream[inp_stream].status |= Push_Eof_Stream_f;
} else {
if (tokstart != NIL && tokstart->Tok != Ord (eot_tok)) {
/* we got the end of file from an abort */
if (Yap_ErrorMessage == "Abort") {
@ -3002,6 +3005,7 @@ do_read(int inp_stream)
Yap_unify_constant (ARG2, MkAtomTerm (AtomEof)));
}
}
}
repeat_cycle:
TR_before_parse = TR;
if (Yap_ErrorMessage || (t = Yap_Parse ()) == 0) {

View File

@ -884,7 +884,7 @@ Yap_tokenizer(int inp_stream)
if(Yap_Option[2]) fprintf(Yap_stderr,"[Token %d %ld]",Ord(kind),(unsigned long int)t->TokInfo);
#endif
if (Yap_ErrorMessage) {
/* insert an error token to inform the system on what happened */
/* insert an error token to inform the system of what happened */
TokEntry *e = (TokEntry *) AllocScannerMemory(sizeof(TokEntry));
if (e == NULL) {
Yap_ErrorMessage = "not enough stack space to read in term";