more bug fixes:
- make readline use packages, not old YAP code - fix ! over backtrack cps - fix write list
This commit is contained in:
@@ -58,7 +58,6 @@ PROGRAMS= \
|
||||
$(srcdir)/random.yap \
|
||||
$(srcdir)/r_session.yap \
|
||||
$(srcdir)/rbtrees.yap \
|
||||
$(srcdir)/readutil.yap \
|
||||
$(srcdir)/regexp.yap \
|
||||
$(srcdir)/rltree.yap \
|
||||
$(srcdir)/splay.yap \
|
||||
|
@@ -1683,7 +1683,7 @@ X_API int PL_is_functor(term_t ts, functor_t f)
|
||||
if (YAP_IsApplTerm(t)) {
|
||||
return FunctorOfTerm(t) == (Functor)ff;
|
||||
} else if (YAP_IsPairTerm(t)) {
|
||||
return FunctorOfTerm(t) == FunctorDot;
|
||||
return ff == FunctorDot;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
@@ -2753,10 +2753,9 @@ int Yap_read_term(term_t t, IOSTREAM *st, term_t vs);
|
||||
int
|
||||
Yap_read_term(term_t t, IOSTREAM *st, term_t vs)
|
||||
{
|
||||
int sno = Yap_LookupSWIStream(st);
|
||||
Term varnames, out, tpos;
|
||||
|
||||
if (!Yap_readTerm(sno, &out, &varnames, NULL, &tpos))
|
||||
if (!Yap_readTerm(st, &out, &varnames, NULL, &tpos))
|
||||
return FALSE;
|
||||
if (!Yap_unify(out, Yap_GetFromSlot(t))) {
|
||||
return FALSE;
|
||||
@@ -2767,46 +2766,19 @@ Yap_read_term(term_t t, IOSTREAM *st, term_t vs)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_StringToTerm(char *s, Term *tp)
|
||||
{
|
||||
IOSTREAM *stream = Sopen_string(NULL, s, -1, "r");
|
||||
int sno;
|
||||
Term out, tpos;
|
||||
|
||||
if (!stream)
|
||||
return FALSE;
|
||||
sno = Yap_LookupSWIStream(stream);
|
||||
if (sno < 0)
|
||||
return FALSE;
|
||||
if (!Yap_readTerm(sno, &out, NULL, tp, &tpos)) {
|
||||
out = 0L;
|
||||
}
|
||||
Yap_CloseStream(sno);
|
||||
Sclose(stream);
|
||||
return out;
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_TermToString(Term t, char *s, unsigned int sz, int flags)
|
||||
{
|
||||
int old_output_stream = Yap_c_output_stream;
|
||||
IOSTREAM *stream = Sopen_string(NULL, s, sz, "w");
|
||||
int sno;
|
||||
int out;
|
||||
|
||||
if (!stream)
|
||||
return FALSE;
|
||||
sno = Yap_LookupSWIStream(stream);
|
||||
|
||||
if (sno < 0)
|
||||
return 0L;
|
||||
Yap_c_output_stream = sno;
|
||||
Yap_StartSlots();
|
||||
Yap_PlWriteToStream (t, sno, flags);
|
||||
stream->bufp = '\0';
|
||||
out = PL_write_term(stream, Yap_InitSlot(t), 1200, 0);
|
||||
Yap_CloseSlots();
|
||||
Yap_c_output_stream = old_output_stream;
|
||||
return EX != NULL;
|
||||
Sclose(stream);
|
||||
return out;
|
||||
}
|
||||
|
||||
Atom
|
||||
|
@@ -1,63 +0,0 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: readutil.yap *
|
||||
* Last rev: 5/12/99 *
|
||||
* mods: *
|
||||
* comments: SWI compatible read utilities *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
:- module(readutil, [
|
||||
read_line_to_codes/2,
|
||||
read_line_to_codes/3,
|
||||
read_stream_to_codes/2,
|
||||
read_stream_to_codes/3,
|
||||
read_file_to_codes/2,
|
||||
read_file_to_codes/3,
|
||||
read_file_to_terms/2,
|
||||
read_file_to_terms/3
|
||||
]).
|
||||
|
||||
|
||||
read_stream_to_codes(Stream, Codes) :-
|
||||
read_stream_to_codes(Stream, Codes, []).
|
||||
|
||||
read_file_to_codes(File, Codes, _) :-
|
||||
open(File, read, Stream),
|
||||
read_stream_to_codes(Stream, Codes, []),
|
||||
close(Stream).
|
||||
|
||||
read_file_to_codes(File, Codes) :-
|
||||
open(File, read, Stream),
|
||||
read_stream_to_codes(Stream, Codes, []),
|
||||
close(Stream).
|
||||
|
||||
read_file_to_terms(File, Codes, _) :-
|
||||
open(File, read, Stream),
|
||||
prolog_read_stream_to_terms(Stream, Codes, []),
|
||||
close(Stream).
|
||||
|
||||
read_file_to_terms(File, Codes) :-
|
||||
open(File, read, Stream),
|
||||
read_stream_to_terms(Stream, Codes, []),
|
||||
close(Stream).
|
||||
|
||||
|
||||
prolog_read_stream_to_terms(Stream, Terms, Terms0) :-
|
||||
read(Stream, Term),
|
||||
(Term == end_of_file ->
|
||||
Terms = Terms0
|
||||
;
|
||||
Terms = [Term|TermsI],
|
||||
prolog_read_stream_to_terms(Stream, TermsI, Terms0)
|
||||
).
|
||||
|
||||
|
Reference in New Issue
Block a user