bootstrap
This commit is contained in:
parent
705a6e9b7f
commit
33de6766a5
69
os/format.c
69
os/format.c
@ -422,6 +422,7 @@ doformat(volatile Term otail, volatile Term oargs, int sno USES_REGS)
|
||||
if (!IsAtomTerm(t))
|
||||
goto do_type_atom_error;
|
||||
yhandle_t sl = Yap_StartSlots();
|
||||
// stream is already locked.
|
||||
Yap_plwrite (t, GLOBAL_Stream+sno, 0, Handle_vars_f|To_heap_f, 1200);
|
||||
Yap_CloseSlots(sl);
|
||||
LOCAL_FormatInfo = &finfo;
|
||||
@ -897,6 +898,71 @@ doformat(volatile Term otail, volatile Term oargs, int sno USES_REGS)
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @pred with_output_to( + _Stream_ , 0:_Goal )
|
||||
*
|
||||
* Evaluate goal _Goal, such that the output will be sent to _Stream_.
|
||||
*
|
||||
* As in format/3, we shall have the special streams `chars`/1, `codes/` and symbtw
|
||||
*
|
||||
*/
|
||||
static Int
|
||||
with_output_to( USES_REGS1 )
|
||||
{
|
||||
int old_out = LOCAL_c_output_stream;
|
||||
int output_stream;
|
||||
Term tin = Deref(ARG1);
|
||||
Functor f;
|
||||
bool out;
|
||||
bool mem_stream = false;
|
||||
if (IsVarTerm(tin)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,tin,"with_output_to/3");
|
||||
return false;
|
||||
}
|
||||
if (IsApplTerm(tin) &&
|
||||
(f = FunctorOfTerm(tin)) &&
|
||||
(f == FunctorAtom || f == FunctorString ||
|
||||
f == FunctorCodes1 || f == FunctorCodes ||
|
||||
f == FunctorChars1 || f == FunctorChars) )
|
||||
{
|
||||
output_stream = Yap_OpenBufWriteStream( PASS_REGS1);
|
||||
} else {
|
||||
/* needs to change LOCAL_c_output_stream for write */
|
||||
output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "format/3");
|
||||
}
|
||||
if (output_stream == -1) {
|
||||
return false;
|
||||
}
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
out = Yap_Execute( Deref(ARG2) PASS_REGS);
|
||||
LOCAL_c_output_stream = old_out;
|
||||
if (mem_stream) {
|
||||
Term tat;
|
||||
Term inp = Deref(ARG1);
|
||||
if (out) {
|
||||
char *s = GLOBAL_Stream[output_stream].u.mem_string.buf;
|
||||
s[GLOBAL_Stream[output_stream].u.mem_string.pos] = '\0';
|
||||
if (f == FunctorAtom) {
|
||||
tat = MkAtomTerm(Yap_LookupAtom(s));
|
||||
} else if (f == FunctorCodes) {
|
||||
tat = Yap_CharsToDiffListOfCodes(s, ArgOfTerm(2,inp) PASS_REGS);
|
||||
} else if (f == FunctorCodes1) {
|
||||
tat = Yap_CharsToListOfCodes(s PASS_REGS);
|
||||
} else if (f == FunctorChars) {
|
||||
tat = Yap_CharsToDiffListOfAtoms(s, ArgOfTerm(2,inp) PASS_REGS);
|
||||
} else if (f == FunctorChars1) {
|
||||
tat = Yap_CharsToListOfAtoms(s PASS_REGS);
|
||||
} else if (f == FunctorString1) {
|
||||
tat = MkStringTerm(s);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
out = Yap_unify(tat,ArgOfTerm(1,inp));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static Int
|
||||
format2(Term tin, Term tf, Term tas USES_REGS)
|
||||
{
|
||||
@ -923,8 +989,8 @@ format2(Term tin, Term tf, Term tas USES_REGS)
|
||||
if (output_stream == -1) {
|
||||
return false;
|
||||
}
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
out = doformat(tf,tas,output_stream PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
if (mem_stream) {
|
||||
Term tat;
|
||||
Term inp = Deref(ARG1);
|
||||
@ -975,4 +1041,5 @@ Yap_InitFormat(void)
|
||||
{
|
||||
Yap_InitCPred ("format", 2, format, SyncPredFlag);
|
||||
Yap_InitCPred ("format", 3, format3, SyncPredFlag);
|
||||
Yap_InitCPred ("with_output_to", 2, with_output_to, SyncPredFlag);
|
||||
}
|
||||
|
55
os/iopreds.c
55
os/iopreds.c
@ -258,6 +258,17 @@ InitStdStream (int sno, SMALLUNSGN flags, FILE * file)
|
||||
|
||||
}
|
||||
|
||||
Term Yap_StreamUserName(int sno)
|
||||
{
|
||||
Term atname;
|
||||
StreamDesc *s = &GLOBAL_Stream[sno];
|
||||
if (s->user_name != 0L) {
|
||||
return (s->user_name);
|
||||
}
|
||||
if ((atname = StreamName(sno)))
|
||||
return atname;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
InitStdStreams (void)
|
||||
@ -287,7 +298,7 @@ Yap_InitStdStreams (void)
|
||||
}
|
||||
|
||||
Int
|
||||
PlIOError (yap_error_number type, Term culprit, char *who, ...)
|
||||
PlIOError (yap_error_number type, Term culprit, const char *who, ...)
|
||||
{
|
||||
if (trueLocalPrologFlag(FILEERRORS_FLAG) == MkIntTerm(1) ||
|
||||
type == RESOURCE_ERROR_MAX_STREAMS /* do not catch resource errors */) {
|
||||
@ -521,8 +532,7 @@ int
|
||||
console_post_process_eof(StreamDesc *s)
|
||||
{
|
||||
CACHE_REGS
|
||||
s->status |= Eof_Stream_f;
|
||||
s->stream_getc = EOFGetc;
|
||||
s->stream_getc = EOFGetc;
|
||||
s->stream_wgetc = get_wchar;
|
||||
if (GLOBAL_CharConversionTable != NULL)
|
||||
s->stream_wgetc_for_read = ISOWGetc;
|
||||
@ -1366,9 +1376,8 @@ binary_file(char *file_name)
|
||||
|
||||
|
||||
static Int
|
||||
open4 ( USES_REGS1 )
|
||||
do_open ( Term file_name, Term t2, Term tlist USES_REGS )
|
||||
{ /* '$open'(+File,+Mode,?Stream,-ReturnCode) */
|
||||
Term file_name, t2, tenc;
|
||||
Atom open_mode;
|
||||
int sno;
|
||||
SMALLUNSGN s;
|
||||
@ -1377,11 +1386,10 @@ binary_file(char *file_name)
|
||||
bool avoid_bom = false, needs_bom = true, bin = false;
|
||||
char *fname;
|
||||
stream_flags_t flags;
|
||||
Term tlist;
|
||||
FILE *fd;
|
||||
encoding_t encoding;
|
||||
Term tenc;
|
||||
|
||||
file_name = Deref(ARG1);
|
||||
// original file name
|
||||
if (IsVarTerm (file_name)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,file_name, "open/3");
|
||||
@ -1398,7 +1406,6 @@ binary_file(char *file_name)
|
||||
fname = RepAtom (AtomOfTerm (file_name))->StrOfAE;
|
||||
}
|
||||
// open mode
|
||||
t2 = Deref (ARG2);
|
||||
if (IsVarTerm (t2)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t2, "open/3");
|
||||
return FALSE;
|
||||
@ -1428,7 +1435,7 @@ binary_file(char *file_name)
|
||||
return(FALSE);
|
||||
}
|
||||
/* get options */
|
||||
xarg *args = Yap_ArgListToVector ( (tlist = Deref(ARG4) ), open_defs, OPEN_END );
|
||||
xarg *args = Yap_ArgListToVector ( tlist, open_defs, OPEN_END );
|
||||
if (args == NULL)
|
||||
return FALSE;
|
||||
/* done */
|
||||
@ -1559,12 +1566,17 @@ binary_file(char *file_name)
|
||||
}
|
||||
}
|
||||
|
||||
static Int
|
||||
open3 ( USES_REGS1 )
|
||||
{ /* '$open'(+File,+Mode,?Stream,-ReturnCode) */
|
||||
ARG4 = TermNil;
|
||||
return open4( PASS_REGS1 );
|
||||
}
|
||||
static Int
|
||||
open3 ( USES_REGS1 )
|
||||
{ /* '$open'(+File,+Mode,?Stream,-ReturnCode) */
|
||||
return do_open(Deref(ARG1), Deref(ARG2), TermNil PASS_REGS );
|
||||
}
|
||||
|
||||
static Int
|
||||
open4 ( USES_REGS1 )
|
||||
{ /* '$open'(+File,+Mode,?Stream,-ReturnCode) */
|
||||
return do_open(Deref(ARG1), Deref(ARG2), Deref( ARG4 ) PASS_REGS );
|
||||
}
|
||||
|
||||
static Int
|
||||
p_file_expansion (USES_REGS1)
|
||||
@ -1666,7 +1678,7 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
|
||||
} else if (IsApplTerm (arg) && FunctorOfTerm (arg) == FunctorStream) {
|
||||
arg = ArgOfTerm (1, arg);
|
||||
if (!IsVarTerm (arg) && IsIntegerTerm (arg)) {
|
||||
sno = IntegerOfTerm(arg);
|
||||
sno = IntegerOfTerm(arg);
|
||||
}
|
||||
}
|
||||
if (sno < 0)
|
||||
@ -1678,19 +1690,18 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
|
||||
if (GLOBAL_Stream[sno].status & Free_Stream_f)
|
||||
{
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
Yap_Error(EXISTENCE_ERROR_STREAM, arg, msg);
|
||||
PlIOError(EXISTENCE_ERROR_STREAM, arg, msg);
|
||||
return (-1);
|
||||
}
|
||||
if ((GLOBAL_Stream[sno].status & kind) == 0)
|
||||
{
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
if (kind & Input_Stream_f)
|
||||
Yap_Error(PERMISSION_ERROR_INPUT_STREAM, arg, msg);
|
||||
PlIOError(PERMISSION_ERROR_INPUT_STREAM, arg, msg);
|
||||
else
|
||||
Yap_Error(PERMISSION_ERROR_OUTPUT_STREAM, arg, msg);
|
||||
PlIOError(PERMISSION_ERROR_OUTPUT_STREAM, arg, msg);
|
||||
return (-1);
|
||||
}
|
||||
jmp_deb(1);
|
||||
return (sno);
|
||||
}
|
||||
|
||||
@ -1819,8 +1830,8 @@ Yap_OpenStream(FILE *fd, char *name, Term file_name, int flags)
|
||||
Yap_InitCPred ("always_prompt_user", 0, always_prompt_user, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("close", 1, close1, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("close", 2, close2, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("open", 4, open4, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("open", 3, open3, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("open", 4, open4, SyncPredFlag);
|
||||
Yap_InitCPred ("open", 3, open3, SyncPredFlag);
|
||||
Yap_InitCPred ("$file_expansion", 2, p_file_expansion, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred ("$open_null_stream", 1, p_open_null_stream, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitIOStreams();
|
||||
|
11
os/iopreds.h
11
os/iopreds.h
@ -162,11 +162,9 @@ typedef struct stream_desc
|
||||
FILE* file;
|
||||
union {
|
||||
struct {
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
#define PLGETC_BUF_SIZE 4096
|
||||
char *buf, *ptr;
|
||||
int left;
|
||||
#endif
|
||||
} file;
|
||||
memHandle mem_string;
|
||||
struct {
|
||||
@ -244,10 +242,15 @@ GetCurInpPos (StreamDesc * inp_stream)
|
||||
return (inp_stream->linecount);
|
||||
}
|
||||
|
||||
Int PlIOError( yap_error_number, Term, char *, ...);
|
||||
Int PlIOError( yap_error_number, Term, const char *, ...);
|
||||
int GetFreeStreamD(void);
|
||||
Term Yap_MkStream (int n);
|
||||
|
||||
bool Yap_PrintWarning( Term twarning );
|
||||
|
||||
|
||||
Int
|
||||
PlIOError (yap_error_number type, Term culprit, const char *who, ...);
|
||||
|
||||
void Yap_plwrite(Term, struct stream_desc *, int, int, int);
|
||||
int Yap_FormatFloat( Float f, const char *s, size_t sz );
|
||||
@ -319,6 +322,8 @@ bool Yap_FetchStreamAlias (int sno, Term t2 USES_REGS);
|
||||
|
||||
INLINE_ONLY inline EXTERN void count_output_char(int ch, StreamDesc *s);
|
||||
|
||||
Term Yap_StreamUserName(int sno);
|
||||
|
||||
INLINE_ONLY inline EXTERN void
|
||||
count_output_char(int ch, StreamDesc *s)
|
||||
{
|
||||
|
@ -208,8 +208,8 @@ prolog_complete(int ignore, int key)
|
||||
static void
|
||||
InitReadline(void) {
|
||||
// don't call readline within emacs
|
||||
if (getenv("ËMACS"))
|
||||
return;
|
||||
//if (getenv("ËMACS"))
|
||||
// return;
|
||||
GLOBAL_Stream[StdInStream].u.irl.buf = NULL;
|
||||
GLOBAL_Stream[StdInStream].u.irl.ptr = NULL;
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
@ -251,6 +251,7 @@ getLine( int inp, int out )
|
||||
LOCAL_PrologMode |= ConsoleGetcMode;
|
||||
|
||||
if (GLOBAL_Stream[out].linepos == 0) { // no output so far
|
||||
fflush(NULL);
|
||||
myrl_line = readline (LOCAL_Prompt);
|
||||
} else {
|
||||
LOCAL_PrologMode |= ConsoleGetcMode;
|
||||
|
1626
os/readterm.c
1626
os/readterm.c
File diff suppressed because it is too large
Load Diff
20
os/streams.c
20
os/streams.c
@ -581,7 +581,7 @@ do_stream_property (int sno, Term opts USES_REGS)
|
||||
break;
|
||||
case STREAM_PROPERTY_POSITION:
|
||||
rc = rc &&
|
||||
stream_position ( sno, args[STREAM_PROPERTY_MODE].tvalue PASS_REGS);
|
||||
stream_position ( sno, args[STREAM_PROPERTY_POSITION].tvalue PASS_REGS);
|
||||
break;
|
||||
case STREAM_PROPERTY_REPOSITION:
|
||||
rc = rc &&
|
||||
@ -628,8 +628,10 @@ cont_stream_property (USES_REGS1)
|
||||
EXTRA_CBACK_ARG (2, 1) = MkIntTerm (i);
|
||||
if (i == MaxStreams)
|
||||
do_cut( true );
|
||||
Yap_unify(ARG1, Yap_MkStream(i-1));
|
||||
return do_stream_property(i-1, Deref(ARG2) PASS_REGS);
|
||||
if ( do_stream_property(i-1, Deref(ARG2) PASS_REGS) ) {
|
||||
Yap_unify(ARG1, Yap_MkStream(i-1));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
UNLOCK(GLOBAL_Stream[i0].streamlock);
|
||||
cut_fail();
|
||||
@ -1018,17 +1020,7 @@ p_user_file_name ( USES_REGS1 )
|
||||
int sno = Yap_CheckStream (ARG1, Input_Stream_f | Output_Stream_f | Append_Stream_f,"user_file_name/2");
|
||||
if (sno < 0)
|
||||
return (FALSE);
|
||||
#if HAVE_SOCKET
|
||||
if (GLOBAL_Stream[sno].status & Socket_Stream_f)
|
||||
tout = MkAtomTerm(AtomSocket);
|
||||
else
|
||||
#endif
|
||||
if (GLOBAL_Stream[sno].status & Pipe_Stream_f)
|
||||
tout = MkAtomTerm(AtomPipe);
|
||||
else if (GLOBAL_Stream[sno].status & InMemory_Stream_f)
|
||||
tout = MkAtomTerm(AtomCharsio);
|
||||
else
|
||||
tout = GLOBAL_Stream[sno].user_name;
|
||||
tout = Yap_StreamUserName(sno);
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
return (Yap_unify_constant (ARG2, tout));
|
||||
}
|
||||
|
84
os/sysbits.c
84
os/sysbits.c
@ -7,6 +7,7 @@
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* PrologPathProkoh
|
||||
* *
|
||||
* File: sysbits.c *
|
||||
* Last rev: 4/03/88 *
|
||||
@ -574,30 +575,18 @@ unix2win( const char *source, char *target, int max)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if O_XOS
|
||||
char *
|
||||
PrologPath(const char *p, char *buf, size_t len)
|
||||
{
|
||||
int flags = (trueGlobalPrologFlag(PLFLAG_FILE_CASE) ? 0 : XOS_DOWNCASE);
|
||||
|
||||
return _xos_canonical_filename(p, buf, len, flags);
|
||||
}
|
||||
|
||||
static char *
|
||||
OsPath(const char *p, char *buf)
|
||||
{
|
||||
if()z
|
||||
trcpy(buf, p);
|
||||
|
||||
return buf;
|
||||
return (char *)p;
|
||||
}
|
||||
#else
|
||||
|
||||
static char *
|
||||
OsPath(const char *X, char *Y) {
|
||||
if (X!=Y && Y) strcpy(Y,X);
|
||||
PrologPath(const char *Y, char *X) {
|
||||
return (char *)Y ;
|
||||
}
|
||||
#endif /* O_XOS */
|
||||
|
||||
|
||||
#if _WIN32
|
||||
#define HAVE_BASENAME 1
|
||||
@ -796,18 +785,29 @@ absolute_file_name( USES_REGS1 )
|
||||
static Int
|
||||
prolog_to_os_filename( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
const char *fp;
|
||||
Term t = Deref(ARG1), t2 = Deref(ARG2);
|
||||
char *fp;
|
||||
char out[MAXPATHLEN+1];
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "absolute_file_name");
|
||||
return false;
|
||||
if (IsVarTerm(t)) {
|
||||
|
||||
if (IsVarTerm(t2)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "prolog_to_os_filename");
|
||||
return false;
|
||||
} else if ( IsAtomTerm(t2) ) {
|
||||
if (!(fp = PrologPath( RepAtom(AtomOfTerm(t2))->StrOfAE, out)))
|
||||
return false;
|
||||
return Yap_unify(ARG1, MkAtomTerm(Yap_LookupAtom( fp )));
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t2, "prolog_to_os_filename");
|
||||
return false;
|
||||
}
|
||||
} else if (!IsAtomTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, "absolute_file_name");
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, "prolog_to_os_filename");
|
||||
return false;
|
||||
}
|
||||
if (!(fp = OsPath( RepAtom(AtomOfTerm(t))->StrOfAE, out)))
|
||||
|
||||
if (!(fp = OsPath( RepAtom(AtomOfTerm(t))->StrOfAE, out)))
|
||||
return false;
|
||||
return Yap_unify(MkAtomTerm(Yap_LookupAtom(fp)), ARG2);
|
||||
}
|
||||
@ -839,6 +839,42 @@ Atom Yap_TemporaryFile( const char *prefix, int *fd) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @pred make_directory(+ _Dir_)
|
||||
|
||||
Create a directory _Dir_. The name of the directory must be an atom.
|
||||
|
||||
*/
|
||||
static Int
|
||||
make_directory( USES_REGS1 )
|
||||
{
|
||||
const char *fd = AtomName(AtomOfTerm(ARG1));
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
if (_mkdir(fd) == -1) {
|
||||
#else
|
||||
if (mkdir(fd, 0777) == -1) {
|
||||
#endif
|
||||
/* return an error number */
|
||||
return false; // errno?
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static Int
|
||||
p_rmdir( USES_REGS1 )
|
||||
{
|
||||
const char *fd = AtomName(AtomOfTerm(ARG1));
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
if (_rmdir(fd) == -1) {
|
||||
#else
|
||||
if (rmdir(fd) == -1) {
|
||||
#endif
|
||||
/* return an error number */
|
||||
return(Yap_unify(ARG2, MkIntTerm(errno)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
initSysPath(Term tlib, Term tcommons, bool dir_done, bool commons_done) {
|
||||
CACHE_REGS
|
||||
@ -3717,7 +3753,9 @@ MSCHandleSignal(DWORD dwCtrlType) {
|
||||
CurrentModule = OPERATING_SYSTEM_MODULE;
|
||||
Yap_InitCPred ("true_file_name", 2, p_true_file_name, SyncPredFlag);
|
||||
Yap_InitCPred ("true_file_name", 3, p_true_file_name3, SyncPredFlag);
|
||||
Yap_InitCPred ("rmdir", 2, p_rmdir, SyncPredFlag);
|
||||
CurrentModule = cm;
|
||||
Yap_InitCPred ("make_directory", 1, make_directory, SyncPredFlag);
|
||||
}
|
||||
|
||||
|
||||
|
@ -290,6 +290,7 @@ write_term ( int output_stream, Term t, xarg *args USES_REGS )
|
||||
prio = 1200;
|
||||
}
|
||||
Yap_plwrite( t, GLOBAL_Stream+output_stream, depth, flags, prio);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
rc = true;
|
||||
|
||||
end:
|
||||
@ -313,7 +314,9 @@ write_term2 ( USES_REGS1 )
|
||||
return false;
|
||||
int output_stream = LOCAL_c_output_stream;
|
||||
if (output_stream == -1) output_stream = 1;
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
@ -333,10 +336,11 @@ write_term3 ( USES_REGS1 )
|
||||
we cannot make recursive Prolog calls */
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
xarg *args = Yap_ArgListToVector ( ARG3, write_defs, WRITE_END );
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
if (args == NULL)
|
||||
return false;
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
@ -357,10 +361,11 @@ write2 ( USES_REGS1 )
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
|
||||
xarg *args = Yap_ArgListToVector ( TermNil, write_defs, WRITE_END );
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
if (args == NULL)
|
||||
return false;
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
@ -383,7 +388,9 @@ write1 ( USES_REGS1 )
|
||||
xarg * args = Yap_ArgListToVector ( TermNil, write_defs, WRITE_END );
|
||||
if (args == NULL)
|
||||
return false;
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
@ -410,7 +417,9 @@ write_canonical1 ( USES_REGS1 )
|
||||
args[WRITE_IGNORE_OPS].tvalue = TermTrue;
|
||||
args[WRITE_QUOTED].used = true;
|
||||
args[WRITE_QUOTED].tvalue = TermTrue;
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
@ -429,14 +438,15 @@ write_canonical ( USES_REGS1 )
|
||||
we cannot make recursive Prolog calls */
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
xarg * args = Yap_ArgListToVector ( TermNil, write_defs, WRITE_END );
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
if (args == NULL)
|
||||
if (args == NULL)
|
||||
return false;
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
args[WRITE_IGNORE_OPS].used = true;
|
||||
args[WRITE_IGNORE_OPS].tvalue = TermTrue;
|
||||
args[WRITE_QUOTED].used = true;
|
||||
args[WRITE_QUOTED].tvalue = TermTrue;
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
@ -462,7 +472,9 @@ writeq1 ( USES_REGS1 )
|
||||
args[WRITE_QUOTED].used = true;
|
||||
args[WRITE_QUOTED].tvalue = TermTrue;
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
Yap_CloseSlots( mySlots );
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
@ -481,14 +493,15 @@ writeq ( USES_REGS1 )
|
||||
we cannot make recursive Prolog calls */
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
xarg *args = Yap_ArgListToVector ( TermNil, write_defs, WRITE_END );
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
if (args == NULL)
|
||||
return false;
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
args[WRITE_NUMBERVARS].used = true;
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
args[WRITE_QUOTED].used = true;
|
||||
args[WRITE_QUOTED].tvalue = TermTrue;
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
@ -516,8 +529,10 @@ print1 ( USES_REGS1 )
|
||||
args[WRITE_PORTRAY].tvalue = TermTrue;
|
||||
args[WRITE_NUMBERVARS].used = true;
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
Yap_CloseSlots( mySlots );
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
EX = NULL;
|
||||
@ -536,14 +551,15 @@ print ( USES_REGS1 )
|
||||
we cannot make recursive Prolog calls */
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
xarg *args = Yap_ArgListToVector ( TermNil, write_defs, WRITE_END );
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
if (args == NULL)
|
||||
return false;
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "write/2");
|
||||
args[WRITE_PORTRAY].used = true;
|
||||
args[WRITE_PORTRAY].tvalue = TermTrue;
|
||||
args[WRITE_NUMBERVARS].used = true;
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
write_term( output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
@ -568,7 +584,9 @@ writeln1 ( USES_REGS1 )
|
||||
return false;
|
||||
args[WRITE_NL].used = true;
|
||||
args[WRITE_NL].tvalue = TermTrue;
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
@ -588,12 +606,15 @@ writeln ( USES_REGS1 )
|
||||
we cannot make recursive Prolog calls */
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
xarg *args = Yap_ArgListToVector ( TermNil, write_defs, WRITE_END );
|
||||
if (args == NULL )
|
||||
return false;
|
||||
int output_stream = Yap_CheckStream (ARG1, Output_Stream_f, "writeln/2");
|
||||
if (args == NULL || output_stream < 0)
|
||||
if (output_stream < 0)
|
||||
return false;
|
||||
args[WRITE_NL].used = true;
|
||||
args[WRITE_NL].tvalue = TermTrue;
|
||||
write_term( output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
Yap_CloseSlots( mySlots );
|
||||
if (EX != 0L) {
|
||||
Term ball = Yap_PopTermFromDB(EX);
|
||||
|
@ -214,4 +214,3 @@ WideHashFunction(wchar_t *CHP)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user