bug fices

This commit is contained in:
Vítor Santos Costa
2016-01-03 02:06:09 +00:00
parent 7a7354fb2b
commit 661f33ac7e
133 changed files with 6000 additions and 9890 deletions

View File

@@ -53,7 +53,9 @@ if (READLINE_FOUND)
# READLINE_readline_LIBRARY, where to find the READLINE library.
# READLINE_ncurses_LIBRARY, where to find the ncurses library [might not be defined]
set( CMAKE_REQUIRED_INCLUDES ${READLINE_INCLUDE_DIR} ${CMAKE_REQUIRED_INCLUDES} )
include_directories (BEFORE ${READLINE_INCLUDE_DIR})
set(YAP_SYSTEM_OPTIONS "readline " ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${READLINE_LIBRARIES} )
check_include_files( "stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H )
check_include_files( "stdio.h;readline/history.h" HAVE_READLINE_HISTORY_H )
@@ -81,15 +83,17 @@ endif (READLINE_FOUND)
set (POSITION_INDEPENDENT_CODE TRUE)
add_library (libYAPOs OBJECT
${YAPOS_SOURCES} )
${YAPOS_SOURCES}
)
set_target_properties(libYAPOs
PROPERTIES
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
POSITION_INDEPENDENT_CODE TRUE
OUTPUT_NAME YAPOs
depends dheap
)
configure_file ("${PROJECT_SOURCE_DIR}/os/YapIOConfig.h.cmake"
@@ -97,6 +101,6 @@ configure_file ("${PROJECT_SOURCE_DIR}/os/YapIOConfig.h.cmake"
set( READLINE_LIBS ${READLINE_LIBRARIES} PARENT_SCOPE)
#set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${GMP_LIBRARIES} )

View File

@@ -105,8 +105,8 @@ Int Yap_peek(int sno) {
Int ch;
s = GLOBAL_Stream + sno;
if ( s->status & Readline_Stream_f) {
ch = Yap_ReadlinePeekChar( sno );
if (s->status & Readline_Stream_f) {
ch = Yap_ReadlinePeekChar(sno);
if (ch == EOFCHAR) {
s->stream_getc = EOFPeek;
s->stream_wgetc = EOFWPeek;
@@ -118,12 +118,12 @@ Int Yap_peek(int sno) {
olinecount = s->linecount;
olinepos = s->linepos;
ch = s->stream_wgetc(sno);
s ->och = ch;
s->och = ch;
if (ch == EOFCHAR) {
s->stream_getc = EOFPeek;
s->stream_wgetc = EOFWPeek;
s->status |= Push_Eof_Stream_f;
return ch;
return ch;
}
s->charcount = ocharcount;
s->linecount = olinecount;
@@ -131,40 +131,39 @@ Int Yap_peek(int sno) {
/* buffer the character */
if (s->encoding == LOCAL_encoding) {
ungetwc(ch, s->file);
} else if (s->encoding == ENC_OCTET ||
s->encoding == ENC_ISO_LATIN1||
s->encoding == ENC_ISO_ASCII) {
} else if (s->encoding == ENC_OCTET || s->encoding == ENC_ISO_LATIN1 ||
s->encoding == ENC_ISO_ASCII) {
ungetc(ch, s->file);
} else if (s->encoding == ENC_ISO_UTF8) {
unsigned char cs[8];
size_t n = put_utf8(cs, ch );
size_t n = put_utf8(cs, ch);
while (n--) {
ungetc(cs[n-1], s->file);
ungetc(cs[n - 1], s->file);
}
} else if (s->encoding == ENC_UTF16_BE) {
/* do the ungetc as if a write .. */
unsigned long int c = ch;
if (c >((1<<16)-1)) {
ungetc(c/1<<16, s->file);
c %= 1<< 16;
if (c > ((1 << 16) - 1)) {
ungetc(c / 1 << 16, s->file);
c %= 1 << 16;
}
ungetc(c, s->file);
} else if (s->encoding == ENC_UTF16_BE) {
/* do the ungetc as if a write .. */
unsigned long int c = ch;
if (c > ((1<<16)-1)) {
ungetc(c/1<<16, s->file);
c %= 1<< 16;
}
if (c > ((1 << 16) - 1)) {
ungetc(c / 1 << 16, s->file);
c %= 1 << 16;
}
} else if (s->encoding == ENC_UTF16_LE) {
/* do the ungetc as if a write .. */
unsigned long int c = ch;
if (c >(( 1<<16)-1)) {
ungetc(c%1<<16, s->file);
c /= 1<< 16;
if (c > ((1 << 16) - 1)) {
ungetc(c % 1 << 16, s->file);
c /= 1 << 16;
}
ungetc(c, s->file);
} else {
} else {
int (*f)(int, int) = s->stream_putc;
s->stream_putc = plUnGetc;
put_wchar(sno, ch);
@@ -512,7 +511,7 @@ static Int put_code(USES_REGS1) { /* '$put'(Stream,N) */
return (FALSE);
if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "put/2");
Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "put/2");
return (FALSE);
}
@@ -552,7 +551,7 @@ static Int put_char_1(USES_REGS1) { /* '$put'(,N) */
LOCK(GLOBAL_Stream[sno].streamlock);
if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "put/2");
Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "put/2");
return (FALSE);
}
GLOBAL_Stream[sno].stream_wputc(sno, ch);
@@ -590,7 +589,7 @@ static Int put_char(USES_REGS1) { /* '$put'(Stream,N) */
return (FALSE);
if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "put/2");
Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "put/2");
return (FALSE);
}
GLOBAL_Stream[sno].stream_wputc(sno, (int)IntegerOfTerm(Deref(ARG2)));
@@ -627,7 +626,7 @@ static Int tab_1(USES_REGS1) { /* nl */
LOCK(GLOBAL_Stream[sno].streamlock);
if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "nl/0");
Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "nl/0");
return (FALSE);
}
@@ -667,7 +666,7 @@ static Int tab(USES_REGS1) { /* nl(Stream) */
if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "nl/0");
Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "nl/0");
return (FALSE);
}
@@ -755,7 +754,7 @@ static Int put_byte(USES_REGS1) { /* '$put_byte'(Stream,N) */
// && strictISOFlag()
) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, NULL);
Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, NULL);
return false;
}
GLOBAL_Stream[sno].stream_putc(sno, ch);
@@ -794,7 +793,7 @@ static Int put_byte_1(USES_REGS1) { /* '$put_byte'(Stream,N) */
//&& strictISOFlag()
) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, ARG1, "get0/2");
Yap_Error(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, ARG1, "get0/2");
return (FALSE);
}
GLOBAL_Stream[sno].stream_putc(sno, ch);
@@ -937,7 +936,7 @@ static Int peek_code(USES_REGS1) { /* at_end_of_stream */
return FALSE;
if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "peek_code/2");
Yap_Error(PERMISSION_ERROR_INPUT_TEXT_STREAM, ARG1, "peek_code/2");
return FALSE;
}
if ((ch = Yap_peek(sno)) < 0) {
@@ -967,7 +966,7 @@ static Int peek_code_1(USES_REGS1) { /* at_end_of_stream */
LOCK(GLOBAL_Stream[sno].streamlock);
if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "peek_code/2");
Yap_Error(PERMISSION_ERROR_INPUT_TEXT_STREAM, ARG1, "peek_code/2");
return FALSE;
}
if ((ch = Yap_peek(sno)) < 0) {
@@ -996,7 +995,7 @@ static Int peek_byte(USES_REGS1) { /* at_end_of_stream */
return (FALSE);
if (!(GLOBAL_Stream[sno].status & Binary_Stream_f)) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_INPUT_STREAM, ARG1, "peek_byte/2");
Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "peek_byte/2");
return (FALSE);
}
if ((ch = dopeek_byte(sno)) < 0) {
@@ -1026,7 +1025,7 @@ static Int peek_byte_1(USES_REGS1) { /* at_end_of_stream */
LOCK(GLOBAL_Stream[sno].streamlock);
if (!(GLOBAL_Stream[sno].status & Binary_Stream_f)) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_INPUT_TEXT_STREAM, ARG1, "peek_byte/2");
Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "peek_byte/2");
return (FALSE);
}
if ((ch = dopeek_byte(sno)) < 0) {

View File

@@ -1220,7 +1220,7 @@ static Int format(Term tout, Term tf, Term tas USES_REGS) {
return false;
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
} else {
yhandle_t sls = Yap_CurrentSlot(PASS_REGS1);
yhandle_t sls = Yap_CurrentSlot();
out = doformat(tf, tas, output_stream PASS_REGS);

View File

@@ -573,7 +573,7 @@ static int EOFWGetc(int sno) {
return EOF;
}
if (ResetEOF(s)) {
Yap_ConsoleOps(s);
Yap_ConsoleOps(s);
return (s->stream_wgetc(sno));
}
return EOF;
@@ -589,7 +589,7 @@ static int EOFGetc(int sno) {
return EOF;
}
if (ResetEOF(s)) {
Yap_ConsoleOps(s);
Yap_ConsoleOps(s);
return s->stream_getc(sno);
}
return EOF;
@@ -646,20 +646,17 @@ int post_process_weof(StreamDesc *s) {
return EOFCHAR;
}
/**
* caled after EOF found a peek, it just calls console_post_process to conclude the job.
*
* @param sno
*
/**
* caled after EOF found a peek, it just calls console_post_process to conclude
*the job.
*
* @param sno
*
* @return EOF
*/
int EOFPeek(int sno) {
return EOFGetc( sno );
}
int EOFPeek(int sno) { return EOFGetc(sno); }
int EOFWPeek(int sno) {
return EOFWGetc( sno );
}
int EOFWPeek(int sno) { return EOFWGetc(sno); }
/* standard routine, it should read from anything pointed by a FILE *.
It could be made more efficient by doing our own buffering and avoiding
@@ -841,7 +838,7 @@ static int get_wchar(int sno) {
if (how_many) {
/* error */
}
return post_process_weof(GLOBAL_Stream+sno);
return post_process_weof(GLOBAL_Stream + sno);
}
wide_char();
}
@@ -1383,10 +1380,8 @@ do_open(Term file_name, Term t2,
}
}
// BOM mess
if ((encoding == ENC_OCTET ||
encoding == ENC_ISO_ASCII ||
encoding == ENC_ISO_LATIN1 ||
encoding == ENC_ISO_UTF8 || bin)) {
if ((encoding == ENC_OCTET || encoding == ENC_ISO_ASCII ||
encoding == ENC_ISO_LATIN1 || encoding == ENC_ISO_UTF8 || bin)) {
avoid_bom = true;
}
if (args[OPEN_BOM].used) {
@@ -1546,7 +1541,7 @@ static int CheckStream__(const char *file, const char *f, int line, Term arg,
if (sname == AtomUser) {
if (kind & Input_Stream_f) {
if (kind & (Output_Stream_f | Append_Stream_f)) {
PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_STREAM, arg,
PlIOError__(file, f, line, PERMISSION_ERROR_OUTPUT_STREAM, arg,
"ambiguous use of 'user' as a stream");
return (-1);
}
@@ -1581,12 +1576,12 @@ static int CheckStream__(const char *file, const char *f, int line, Term arg,
if ((GLOBAL_Stream[sno].status & Input_Stream_f) &&
!(kind & Input_Stream_f)) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_STREAM, arg, msg);
PlIOError__(file, f, line, PERMISSION_ERROR_OUTPUT_STREAM, arg, msg);
}
if ((GLOBAL_Stream[sno].status & (Append_Stream_f | Output_Stream_f)) &&
!(kind & Output_Stream_f)) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
PlIOError__(file, f, line, PERMISSION_ERROR_OUTPUT_STREAM, arg, msg);
PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_STREAM, arg, msg);
}
return (sno);
}
@@ -1602,7 +1597,12 @@ int Yap_CheckTextStream__(const char *file, const char *f, int line, Term arg,
if ((sno = CheckStream__(file, f, line, arg, kind, msg)) < 0)
return -1;
if ((GLOBAL_Stream[sno].status & Binary_Stream_f)) {
PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_BINARY_STREAM, arg, msg);
if (kind == Input_Stream_f)
PlIOError__(file, f, line, PERMISSION_ERROR_INPUT_BINARY_STREAM, arg,
msg);
else
PlIOError__(file, f, line, PERMISSION_ERROR_OUTPUT_BINARY_STREAM, arg,
msg);
UNLOCK(GLOBAL_Stream[sno].streamlock);
return -1;
}

View File

@@ -351,12 +351,12 @@ Term Yap_syntax_error(TokEntry *errtok, int sno) {
tn[0] = Yap_MkApplTerm(FunctorShortSyntaxError, 1, &terr);
tn[1] = TermNil;
terr = Yap_MkApplTerm(FunctorError, 2, tn);
#if DEBUG
if (Yap_ExecutionMode == YAP_BOOT_MODE) {
fprintf(stderr, "SYNTAX ERROR while booting: ");
Yap_DebugPlWriteln( terr );
}
#endif
#if DEBUG
if (Yap_ExecutionMode == YAP_BOOT_MODE) {
fprintf(stderr, "SYNTAX ERROR while booting: ");
Yap_DebugPlWriteln(terr);
}
#endif
return terr;
}
@@ -400,6 +400,7 @@ static xarg *setReadEnv(Term opts, FEnv *fe, struct renv *re, int inp_stream) {
if (args == NULL) {
return NULL;
}
re->bq = getBackQuotesFlag();
if (args[READ_MODULE].used) {
CurrentModule = args[READ_MODULE].tvalue;
@@ -456,7 +457,8 @@ static xarg *setReadEnv(Term opts, FEnv *fe, struct renv *re, int inp_stream) {
re->prio = IntegerOfTerm(args[READ_PRIORITY].tvalue);
if (re->prio > GLOBAL_MaxPriority) {
Yap_Error(DOMAIN_ERROR_OPERATOR_PRIORITY, opts,
"max priority in Prolog is %d, not %ld", GLOBAL_MaxPriority, re->prio);
"max priority in Prolog is %d, not %ld", GLOBAL_MaxPriority,
re->prio);
}
} else {
re->prio = LOCAL_default_priority;
@@ -660,7 +662,7 @@ static parser_state_t scan(REnv *re, FEnv *fe, int inp_stream) {
and floats */
LOCAL_tokptr = LOCAL_toktide =
Yap_tokenizer(GLOBAL_Stream + inp_stream, false, &fe->tpos);
Yap_tokenizer(GLOBAL_Stream + inp_stream, false, &fe->tpos);
if (LOCAL_ErrorMessage)
return YAP_SCANNING_ERROR;
if (LOCAL_tokptr->Tok != Ord(eot_tok)) {
@@ -809,6 +811,16 @@ Term Yap_read_term(int inp_stream, Term opts, int nargs) {
return fe.t;
}
}
if (fe.t) {
if (fe.reading_clause &&
!complete_clause_processing(&fe, LOCAL_tokptr, fe.t))
fe.t = 0;
else if (!fe.reading_clause && !complete_processing(&fe, LOCAL_tokptr))
fe.t = 0;
}
#if EMACS
first_char = tokstart->TokPos;
#endif /* EMACS */
return fe.t;
}
@@ -819,7 +831,7 @@ static Int
if ((rc = Yap_read_term(LOCAL_c_input_stream, ARG2, 2)) == 0)
return FALSE;
Term tf = Yap_GetFromSlot(h);
Yap_RecoverSlots(1, h PASS_REGS);
Yap_RecoverSlots(1, h);
return Yap_unify(tf, rc);
}
@@ -837,7 +849,7 @@ static Int read_term(
out = Yap_read_term(inp_stream, ARG3, 3);
UNLOCK(GLOBAL_Stream[inp_stream].streamlock);
Term tf = Yap_GetFromSlot(h);
Yap_RecoverSlots(1, h PASS_REGS);
Yap_RecoverSlots(1, h);
return out != 0L && Yap_unify(tf, out);
}
@@ -987,7 +999,7 @@ static Int read_clause2(USES_REGS1) {
yhandle_t h = Yap_InitSlot(ARG1);
rc = Yap_read_term(LOCAL_c_input_stream, Deref(ARG2), -2);
Term tf = Yap_GetFromSlot(h);
Yap_RecoverSlots(1, h PASS_REGS);
Yap_RecoverSlots(1, h);
return rc && Yap_unify(tf, rc);
}
@@ -1025,7 +1037,7 @@ static Int read_clause(
out = Yap_read_term(inp_stream, t3, -3);
UNLOCK(GLOBAL_Stream[inp_stream].streamlock);
Term tf = Yap_GetFromSlot(h);
Yap_RecoverSlots(1, h PASS_REGS);
Yap_RecoverSlots(1, h);
return out && Yap_unify(tf, out);
}
@@ -1181,7 +1193,7 @@ Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, int prio,
*bindings = Yap_GetFromSlot(sl);
}
if (bindings) {
Yap_RecoverSlots(sl, 1 PASS_REGS);
Yap_RecoverSlots(sl, 1);
}
return rval;
}

View File

@@ -241,7 +241,7 @@ read_stream_to_terms(USES_REGS1)
RESET_VARIABLE(HR);
RESET_VARIABLE(HR+1);
hd = (CELL)HR;
Yap_PutInSlot(news, (CELL)(HR+1) PASS_REGS);
Yap_PutInSlot(news, (CELL)(HR+1));
HR += 2;
while ((hd=Yap_read_term(sno, TermNil, 2)) == 0L)
;
@@ -253,7 +253,7 @@ read_stream_to_terms(USES_REGS1)
} else {
CELL *newpt = (CELL*)Yap_GetFromSlot(news);
*pt =AbsPair(newpt-1);
Yap_PutInSlot(tails, (CELL)newpt PASS_REGS);
Yap_PutInSlot(tails, (CELL)newpt);
}
}
UNLOCK(GLOBAL_Stream[sno].streamlock);

View File

@@ -718,8 +718,8 @@ void Yap_walltime_interval(Int *now,Int *interval)
Yap_ReInitWTime (void)
{
Yap_InitWTime();
if (Yap_global->LastWTimePtr_ != NULL)
Yap_FreeCodeSpace(Yap_global->LastWTimePtr_);
if (GLOBAL_LastWTimePtr != NULL)
Yap_FreeCodeSpace(GLOBAL_LastWTimePtr);
Yap_InitLastWTime();
}

View File

@@ -20,7 +20,7 @@ static char SccsId[] = "%W% %G%";
/*
* This file includes the definition of a miscellania of standard predicates
* for yap refering to: Files and GLOBAL_Streams, Simple Input/Output,
* for yap refering to: Files and GLOBAL_Streams, Simple Input/Output,
*
*/
@@ -49,7 +49,7 @@ static char SccsId[] = "%W% %G%";
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#if HAVE_SYS_SELECT_H && !_MSC_VER && !defined(__MINGW32__)
#if HAVE_SYS_SELECT_H && !_MSC_VER && !defined(__MINGW32__)
#include <sys/select.h>
#endif
#ifdef HAVE_UNISTD_H
@@ -77,7 +77,7 @@ static char SccsId[] = "%W% %G%";
#if !HAVE_STRNCPY
#define strncpy(X,Y,Z) strcpy(X,Y)
#endif
#if _MSC_VER || defined(__MINGW32__)
#if _MSC_VER || defined(__MINGW32__)
#if HAVE_SOCKET
#include <winsock2.h>
#endif
@@ -88,7 +88,7 @@ static char SccsId[] = "%W% %G%";
#endif
#include "iopreds.h"
#if _MSC_VER || defined(__MINGW32__)
#if _MSC_VER || defined(__MINGW32__)
#define SYSTEM_STAT _stat
#else
#define SYSTEM_STAT stat
@@ -102,7 +102,7 @@ static char SccsId[] = "%W% %G%";
int beam_write ( USES_REGS1 )
{
Yap_StartSlots();
Yap_plwrite (ARG1, GLOBAL_Stream+LOCAL_output_stream, 0, 0, 1200);
Yap_plwrite (ARG1, GLOBAL_Stream+LOCAL_output_stream, 0, 0, GLOBAL_MaxPriority);
Yap_CloseSlots();
if (EX != 0L) {
Term ball = Yap_PopTermFromDB(EX);
@@ -122,7 +122,7 @@ p_write ( USES_REGS1 )
/* notice: we must have ASP well set when using portray, otherwise
we cannot make recursive Prolog calls */
yhandle_t mySlots = Yap_StartSlots();
Yap_plwrite (ARG2, GLOBAL_Stream+LOCAL_output_stream, 0, flags, 1200);
Yap_plwrite (ARG2, GLOBAL_Stream+LOCAL_output_stream, 0, flags, GLOBAL_MaxPriority);
Yap_CloseSlots( mySlots );
if (EX != 0L) {
Term ball = Yap_PopTermFromDB(EX);
@@ -159,8 +159,7 @@ p_write2_prio ( USES_REGS1 )
Int flags = IntegerOfTerm(Deref(ARG2));
int stream_f;
stream_f = Output_Stream_f;
LOCAL_output_stream = CheckStream (ARG1, stream_f, "write/2");
LOCAL_output_stream = CheckTextStream(ARG1, Output_Stream_f, "write/2");
if (LOCAL_output_stream == -1) {
LOCAL_output_stream = old_output_stream;
return(FALSE);
@@ -185,7 +184,7 @@ static Int
p_write2 ( USES_REGS1 )
{ /* '$write'(+Stream,+Flags,?Term) */
int old_output_stream = LOCAL_output_stream;
LOCAL_output_stream = CheckStream (ARG1, Output_Stream_f, "write/2");
LOCAL_output_stream = CheckTextStream(ARG1, Output_Stream_f, "write/2");
if (LOCAL_output_stream == -1) {
LOCAL_output_stream = old_output_stream;
return(FALSE);
@@ -194,7 +193,7 @@ p_write2 ( USES_REGS1 )
/* notice: we must have ASP well set when using portray, otherwise
we cannot make recursive Prolog calls */
yhandle_t myslots = Yap_StartSlots();
Yap_plwrite (ARG3, GLOBAL_Stream+LOCAL_output_stream, 0, (int) IntOfTerm (Deref (ARG2)), 1200);
Yap_plwrite (ARG3, GLOBAL_Stream+LOCAL_output_stream, 0, (int) IntOfTerm (Deref (ARG2)), GLOBAL_MaxPriority);
Yap_CloseSlots(myslots);
LOCAL_output_stream = old_output_stream;
if (EX != 0L) {

View File

@@ -148,36 +148,8 @@ void Yap_init_socks(char *host, long interface_port);
extern int errno;
#endif
INLINE_ONLY EXTERN UInt inline HashFunction(const unsigned char *);
INLINE_ONLY EXTERN UInt inline WideHashFunction(wchar_t *);
INLINE_ONLY EXTERN inline UInt HashFunction(const unsigned char *CHP) {
/* djb2 */
UInt hash = 5381;
UInt c;
while ((c = (UInt)(*CHP++)) != '\0') {
/* hash = ((hash << 5) + hash) + c; hash * 33 + c */
hash = hash * 33 ^ c;
}
return hash;
/*
UInt OUT=0, i = 1;
while(*CHP != '\0') { OUT += (UInt)(*CHP++); }
return OUT;
*/
}
INLINE_ONLY EXTERN UInt inline WideHashFunction(wchar_t *CHP) {
UInt hash = 5381;
UInt c;
while ((c = *CHP++) != '\0') {
hash = hash * 33 ^ c;
}
return hash;
}
uint64_t HashFunction(const unsigned char *);
uint64_t WideHashFunction(wchar_t *);
INLINE_ONLY inline EXTERN Term MkCharTerm(Int c);