fix BOM trouble

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2065 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2008-01-28 10:42:20 +00:00
parent 44e4a953e4
commit 456b4eb6c1
4 changed files with 30 additions and 30 deletions

View File

@ -10,8 +10,13 @@
* File: c_interface.c * * File: c_interface.c *
* comments: c_interface primitives definition * * comments: c_interface primitives definition *
* * * *
* Last rev: $Date: 2007-12-05 12:17:23 $,$Author: vsc $ * * Last rev: $Date: 2008-01-28 10:42:19 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $ * $Log: not supported by cvs2svn $
* Revision 1.104 2007/12/05 12:17:23 vsc
* improve JT
* fix graph compatibility with SICStus
* re-export declaration.
*
* Revision 1.103 2007/11/16 14:58:40 vsc * Revision 1.103 2007/11/16 14:58:40 vsc
* implement sophisticated operations with matrices. * implement sophisticated operations with matrices.
* *
@ -883,10 +888,13 @@ YAP_ExtraSpace(void)
{ {
void *ptr; void *ptr;
BACKUP_B(); BACKUP_B();
BACKUP_H();
/* find a pointer to extra space allocable */ /* find a pointer to extra space allocable */
ptr = (void *)((CELL *)(B+1)+P->u.lds.s); ptr = (void *)((CELL *)(B+1)+P->u.lds.s);
B->cp_h = H;
RECOVER_H();
RECOVER_B(); RECOVER_B();
return(ptr); return(ptr);
} }

View File

@ -1466,7 +1466,7 @@ DefaultGets (int sno, UInt size, char *buf)
while((ch = *buf++ = s->stream_getc(sno)) != while((ch = *buf++ = s->stream_getc(sno)) !=
-1 && ch != 10 && --size); -1 && ch != 10 && --size);
*buf++ = '\0'; *buf++ = '\0';
return pt-buf; return (buf-pt)-1;
} }
/* read from memory */ /* read from memory */
@ -1583,6 +1583,7 @@ PlUnGetc (int sno)
} }
} else { } else {
s->stream_getc = PlGetc; s->stream_getc = PlGetc;
s->stream_gets = PlGetsFunc();
} }
return(post_process_read_char(ch, s)); return(post_process_read_char(ch, s));
} }
@ -1729,6 +1730,7 @@ get_wchar(int sno)
Stream[sno].och = ch; Stream[sno].och = ch;
Stream[sno].stream_getc = PlUnGetc; Stream[sno].stream_getc = PlUnGetc;
Stream[sno].stream_wgetc = get_wchar; Stream[sno].stream_wgetc = get_wchar;
Stream[sno].stream_gets = DefaultGets;
return och; return och;
} }
if (!how_many) { if (!how_many) {
@ -2104,6 +2106,7 @@ check_bom(int sno, StreamDesc *st)
st->och = ch; st->och = ch;
st->stream_getc = PlUnGetc376; st->stream_getc = PlUnGetc376;
st->stream_wgetc = get_wchar; st->stream_wgetc = get_wchar;
st->stream_gets = DefaultGets;
return TRUE; return TRUE;
} else { } else {
st->status |= HAS_BOM_f; st->status |= HAS_BOM_f;
@ -2118,6 +2121,7 @@ check_bom(int sno, StreamDesc *st)
st->och = ch; st->och = ch;
st->stream_getc = PlUnGetc377; st->stream_getc = PlUnGetc377;
st->stream_wgetc = get_wchar; st->stream_wgetc = get_wchar;
st->stream_gets = DefaultGets;
return TRUE; return TRUE;
} else { } else {
st->status |= HAS_BOM_f; st->status |= HAS_BOM_f;
@ -2131,6 +2135,7 @@ check_bom(int sno, StreamDesc *st)
st->och = ch; st->och = ch;
st->stream_getc = PlUnGetc357; st->stream_getc = PlUnGetc357;
st->stream_wgetc = get_wchar; st->stream_wgetc = get_wchar;
st->stream_gets = DefaultGets;
return TRUE; return TRUE;
} else { } else {
ch = st->stream_getc(sno); ch = st->stream_getc(sno);
@ -2138,6 +2143,7 @@ check_bom(int sno, StreamDesc *st)
st->och = ch; st->och = ch;
st->stream_getc = PlUnGetc357273; st->stream_getc = PlUnGetc357273;
st->stream_wgetc = get_wchar; st->stream_wgetc = get_wchar;
st->stream_gets = DefaultGets;
return TRUE; return TRUE;
} else { } else {
st->status |= HAS_BOM_f; st->status |= HAS_BOM_f;
@ -2149,6 +2155,7 @@ check_bom(int sno, StreamDesc *st)
st->och = ch; st->och = ch;
st->stream_getc = PlUnGetc; st->stream_getc = PlUnGetc;
st->stream_wgetc = get_wchar; st->stream_wgetc = get_wchar;
st->stream_gets = DefaultGets;
return TRUE; return TRUE;
} }
} }
@ -3338,6 +3345,7 @@ p_peek_byte (void)
/* mark a special function to recover this character */ /* mark a special function to recover this character */
s->stream_getc = PlUnGetc; s->stream_getc = PlUnGetc;
s->stream_wgetc = get_wchar; s->stream_wgetc = get_wchar;
s->stream_gets = DefaultGets;
if (CharConversionTable != NULL) if (CharConversionTable != NULL)
s->stream_wgetc_for_read = ISOWGetc; s->stream_wgetc_for_read = ISOWGetc;
else else
@ -3383,6 +3391,7 @@ p_peek (void)
/* mark a special function to recover this character */ /* mark a special function to recover this character */
s->stream_getc = PlUnGetc; s->stream_getc = PlUnGetc;
s->stream_wgetc = get_wchar; s->stream_wgetc = get_wchar;
s->stream_gets = DefaultGets;
if (CharConversionTable != NULL) if (CharConversionTable != NULL)
s->stream_wgetc_for_read = ISOWGetc; s->stream_wgetc_for_read = ISOWGetc;
else else
@ -4269,14 +4278,6 @@ p_get (void)
if (sno < 0) if (sno < 0)
return FALSE; return FALSE;
if (Stream[sno].stream_getc == PlUnGetc) {
ch = PlUnGetc(sno);
if (ch <= 32 && ch >= 0) {
/* done */
UNLOCK(Stream[sno].streamlock);
return Yap_unify_constant (ARG2, MkIntegerTerm (ch));
}
}
status = Stream[sno].status; status = Stream[sno].status;
if (status & Binary_Stream_f) { if (status & Binary_Stream_f) {
UNLOCK(Stream[sno].streamlock); UNLOCK(Stream[sno].streamlock);
@ -4297,17 +4298,13 @@ p_get0 (void)
if (sno < 0) if (sno < 0)
return(FALSE); return(FALSE);
if (Stream[sno].stream_getc == PlUnGetc) { status = Stream[sno].status;
out = PlUnGetc(sno); if (status & Binary_Stream_f) {
} else { UNLOCK(Stream[sno].streamlock);
status = Stream[sno].status; Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "get0/2");
if (status & Binary_Stream_f) { return FALSE;
UNLOCK(Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "get0/2");
return FALSE;
}
out = get_wchar(sno);
} }
out = get_wchar(sno);
UNLOCK(Stream[sno].streamlock); UNLOCK(Stream[sno].streamlock);
return (Yap_unify_constant (ARG2, MkIntegerTerm (out)) ); return (Yap_unify_constant (ARG2, MkIntegerTerm (out)) );
} }
@ -5155,12 +5152,8 @@ format(volatile Term otail, volatile Term oargs, int sno)
if (targ > tnum-1 || has_repeats) if (targ > tnum-1 || has_repeats)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
if (!LCL0[-30])
fprintf(stderr,"OOPS %d\n",LCL0-ASP);
Yap_StartSlots(); Yap_StartSlots();
Yap_plwrite (t, f_putc, Handle_vars_f|To_heap_f); Yap_plwrite (t, f_putc, Handle_vars_f|To_heap_f);
if (!LCL0[-30])
fprintf(stderr,"OOPS %d\n",LCL0-ASP);
FormatInfo = &finfo; FormatInfo = &finfo;
ASP++; ASP++;
break; break;
@ -5284,11 +5277,7 @@ format(volatile Term otail, volatile Term oargs, int sno)
if (Stream[sno].status & InMemory_Stream_f) { if (Stream[sno].status & InMemory_Stream_f) {
Stream[sno].u.mem_string.error_handler = old_handler; Stream[sno].u.mem_string.error_handler = old_handler;
} }
if (!LCL0[-30])
fprintf(stderr,"OOPS 3 %d\n",LCL0-ASP);
format_clean_up(finfo.format_base, fstr, targs); format_clean_up(finfo.format_base, fstr, targs);
if (!LCL0[-30])
fprintf(stderr,"OOPS 4 %d\n",LCL0-ASP);
return (TRUE); return (TRUE);
} }

View File

@ -10,7 +10,7 @@
* File: Yap.h.m4 * * File: Yap.h.m4 *
* mods: * * mods: *
* comments: main header file for YAP * * comments: main header file for YAP *
* version: $Id: Yap.h,v 1.24 2008-01-25 00:21:28 vsc Exp $ * * version: $Id: Yap.h,v 1.25 2008-01-28 10:42:20 vsc Exp $ *
*************************************************************************/ *************************************************************************/
#include "config.h" #include "config.h"
@ -165,7 +165,7 @@
#elif SIZEOF_INT_P==8 #elif SIZEOF_INT_P==8
# if SIZEOF_INT==8 #if SIZEOF_INT==8
/* */ typedef int Int; /* */ typedef int Int;
/* */ typedef unsigned int UInt; /* */ typedef unsigned int UInt;

View File

@ -17,6 +17,9 @@
<h2>Yap-5.1.3:</h2> <h2>Yap-5.1.3:</h2>
<ul> <ul>
<li> FIXED: testing for BOM forced incorrect execution of gets (obs
from A N Saravanaraj), also fixed stup call to Ungetc in getc and
friends.</li>
<li> FIXED: bad handling of trail overflow.</li> <li> FIXED: bad handling of trail overflow.</li>
<li> FIXED: overflow at entry goal (obs from Paulo Moura).</li> <li> FIXED: overflow at entry goal (obs from Paulo Moura).</li>
<li> FIXED: bug with signals while process wasa dying (obs from Paulo Moura).</li> <li> FIXED: bug with signals while process wasa dying (obs from Paulo Moura).</li>