Merge branch 'master' of github.com:vscosta/yap-6.3
This commit is contained in:
commit
9fcbfca1fa
15
C/cdmgr.c
15
C/cdmgr.c
@ -1347,9 +1347,9 @@ static void expand_consult(void) {
|
||||
/* next, set up pointers correctly */
|
||||
new_cs += (LOCAL_ConsultSp - LOCAL_ConsultLow);
|
||||
/* put LOCAL_ConsultBase at same offset as before move */
|
||||
LOCAL_ConsultBase = LOCAL_ConsultBase + (new_cs - LOCAL_ConsultSp);
|
||||
/* new consult pointer */
|
||||
LOCAL_ConsultSp = new_cs;
|
||||
LOCAL_ConsultBase = new_cl + ((LOCAL_ConsultBase - LOCAL_ConsultLow)+InitialConsultCapacity);
|
||||
/* new consult pointer */
|
||||
LOCAL_ConsultSp = new_cl + ((LOCAL_ConsultSp - LOCAL_ConsultLow)+InitialConsultCapacity);
|
||||
/* new end of memory */
|
||||
LOCAL_ConsultLow = new_cl;
|
||||
}
|
||||
@ -1389,9 +1389,9 @@ static int not_was_reconsulted(PredEntry *p, Term t, int mode) {
|
||||
//%s\n",NameOfFunctor(p->FunctorOfPred)->StrOfAE,p->src.OwnerFile->StrOfAE);
|
||||
}
|
||||
if (mode) {
|
||||
if (LOCAL_ConsultSp == LOCAL_ConsultLow + 1) {
|
||||
expand_consult();
|
||||
}
|
||||
if (LOCAL_ConsultSp <= LOCAL_ConsultLow + 6) {
|
||||
expand_consult();
|
||||
}
|
||||
--LOCAL_ConsultSp;
|
||||
LOCAL_ConsultSp->p = p0;
|
||||
if (LOCAL_ConsultBase[1].mode &&
|
||||
@ -2011,6 +2011,9 @@ static void init_consult(int mode, const unsigned char *file) {
|
||||
if (!LOCAL_ConsultSp) {
|
||||
InitConsultStack();
|
||||
}
|
||||
if (LOCAL_ConsultSp >= LOCAL_ConsultLow + 6) {
|
||||
expand_consult();
|
||||
}
|
||||
LOCAL_ConsultSp--;
|
||||
LOCAL_ConsultSp->filename = file;
|
||||
LOCAL_ConsultSp--;
|
||||
|
@ -222,11 +222,11 @@ static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
|
||||
#ifdef USE_GMP
|
||||
else if (IsBigIntTerm(d0)) {
|
||||
if (IsIntTerm(d1)) {
|
||||
out = Yap_gmp_tcmp_int_big(d0, IntOfTerm(d1));
|
||||
out = Yap_gmp_tcmp_big_int(d0, IntOfTerm(d1));
|
||||
} else if (IsFloatTerm(d1)) {
|
||||
out = 1;
|
||||
} else if (IsLongIntTerm(d1)) {
|
||||
out = Yap_gmp_tcmp_int_big(d0, LongIntOfTerm(d1));
|
||||
out = Yap_gmp_tcmp_big_int(d0, LongIntOfTerm(d1));
|
||||
} else if (IsBigIntTerm(d1)) {
|
||||
out = Yap_gmp_tcmp_big_big(d0, d1);
|
||||
} else if (IsRefTerm(d1))
|
||||
|
@ -2503,7 +2503,8 @@ static Term GetDBTerm(DBTerm *DBSP, int src USES_REGS) {
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
if (HR + NOf > ASP - EventFlag / sizeof(CELL)) {
|
||||
if (LOCAL_PrologMode & InErrorMode) {
|
||||
if (HR + NOf > ASP)
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
if (HR + NOf > ASP)
|
||||
fprintf(stderr,
|
||||
"\n\n [ FATAL ERROR: No Stack for Error Handling ]\n");
|
||||
Yap_exit(1);
|
||||
@ -2713,6 +2714,9 @@ static PredEntry *new_lu_entry(Term t) {
|
||||
pe->PredFlags |= LogUpdatePredFlag;
|
||||
if (IsAtomTerm(t)) {
|
||||
pe->PredFlags |= AtomDBPredFlag;
|
||||
pe->FunctorOfPred = (Functor)AtomOfTerm(t);
|
||||
} else {
|
||||
pe->FunctorOfPred = FunctorOfTerm(t);
|
||||
}
|
||||
pe->ArityOfPE = 3;
|
||||
pe->OpcodeOfPred = Yap_opcode(_op_fail);
|
||||
|
215
C/errors.c
215
C/errors.c
@ -35,7 +35,7 @@
|
||||
#if DEBUG
|
||||
void Yap_PrintPredName(PredEntry *ap) {
|
||||
CACHE_REGS
|
||||
Term tmod = ap->ModuleOfPred;
|
||||
Term tmod = ap->ModuleOfPred;
|
||||
if (!tmod)
|
||||
tmod = TermProlog;
|
||||
#if THREADS
|
||||
@ -91,7 +91,7 @@ void Yap_PrintPredName(PredEntry *ap) {
|
||||
|
||||
bool Yap_Warning(const char *s, ...) {
|
||||
CACHE_REGS
|
||||
va_list ap;
|
||||
va_list ap;
|
||||
PredEntry *pred;
|
||||
bool rc;
|
||||
Term ts[2];
|
||||
@ -134,8 +134,8 @@ bool Yap_Warning(const char *s, ...) {
|
||||
|
||||
bool Yap_PrintWarning(Term twarning) {
|
||||
CACHE_REGS
|
||||
PredEntry *pred = RepPredProp(PredPropByFunc(
|
||||
FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2;
|
||||
PredEntry *pred = RepPredProp(PredPropByFunc(
|
||||
FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2;
|
||||
Term cmod = ( CurrentModule == PROLOG_MODULE ? TermProlog : CurrentModule );
|
||||
bool rc;
|
||||
Term ts[2];
|
||||
@ -149,10 +149,10 @@ bool Yap_PrintWarning(Term twarning) {
|
||||
LOCAL_within_print_message = true;
|
||||
if (pred->OpcodeOfPred == UNDEF_OPCODE ||
|
||||
pred->OpcodeOfPred == FAIL_OPCODE
|
||||
) {
|
||||
fprintf(stderr, "warning message:\n");
|
||||
Yap_DebugPlWrite(twarning);
|
||||
fprintf(stderr, "\n");
|
||||
) {
|
||||
fprintf(stderr, "warning message:\n");
|
||||
Yap_DebugPlWrite(twarning);
|
||||
fprintf(stderr, "\n");
|
||||
LOCAL_DoingUndefp = false;
|
||||
LOCAL_within_print_message = false;
|
||||
CurrentModule = cmod;
|
||||
@ -170,7 +170,7 @@ bool Yap_PrintWarning(Term twarning) {
|
||||
|
||||
bool Yap_HandleError__(const char *file, const char *function, int lineno, const char *s, ...) {
|
||||
CACHE_REGS
|
||||
yap_error_number err = LOCAL_Error_TYPE;
|
||||
yap_error_number err = LOCAL_Error_TYPE;
|
||||
const char *serr;
|
||||
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
@ -209,7 +209,7 @@ bool Yap_HandleError__(const char *file, const char *function, int lineno, const
|
||||
|
||||
int Yap_SWIHandleError(const char *s, ...) {
|
||||
CACHE_REGS
|
||||
yap_error_number err = LOCAL_Error_TYPE;
|
||||
yap_error_number err = LOCAL_Error_TYPE;
|
||||
char *serr;
|
||||
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
@ -249,36 +249,36 @@ int Yap_SWIHandleError(const char *s, ...) {
|
||||
void Yap_RestartYap(int flag) {
|
||||
CACHE_REGS
|
||||
#if PUSH_REGS
|
||||
restore_absmi_regs(&Yap_standard_regs);
|
||||
restore_absmi_regs(&Yap_standard_regs);
|
||||
#endif
|
||||
siglongjmp(LOCAL_RestartEnv, 1);
|
||||
}
|
||||
|
||||
static void error_exit_yap(int value) {
|
||||
CACHE_REGS
|
||||
if (!(LOCAL_PrologMode & BootMode)) {
|
||||
if (!(LOCAL_PrologMode & BootMode)) {
|
||||
|
||||
#if DEBUG
|
||||
#endif
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n Exiting ....\n");
|
||||
#if HAVE_BACKTRACE
|
||||
void *callstack[256];
|
||||
int i;
|
||||
int frames = backtrace(callstack, 256);
|
||||
char** strs = backtrace_symbols(callstack, frames);
|
||||
fprintf(stderr, "Execution stack:\n");
|
||||
for (i = 0; i < frames; ++i) {
|
||||
fprintf(stderr, " %s\n", strs[i]);
|
||||
void *callstack[256];
|
||||
int i;
|
||||
int frames = backtrace(callstack, 256);
|
||||
char** strs = backtrace_symbols(callstack, frames);
|
||||
fprintf(stderr, "Execution stack:\n");
|
||||
for (i = 0; i < frames; ++i) {
|
||||
fprintf(stderr, " %s\n", strs[i]);
|
||||
|
||||
}
|
||||
free(strs);
|
||||
}
|
||||
free(strs);
|
||||
#endif
|
||||
Yap_exit(value);
|
||||
Yap_exit(value);
|
||||
}
|
||||
|
||||
/* This needs to be a static because I can't trust the stack (WIN32), and
|
||||
I can't trust the Yap stacks (error) */
|
||||
I can't trust the Yap stacks (error) */
|
||||
#define YAP_BUF_SIZE 512
|
||||
|
||||
static char tmpbuf[YAP_BUF_SIZE];
|
||||
@ -299,51 +299,51 @@ static char tmpbuf[YAP_BUF_SIZE];
|
||||
#undef E2
|
||||
#undef END_ERRORS
|
||||
|
||||
#define BEGIN_ERROR_CLASSES() \
|
||||
static Term mkerrorct(yap_error_class_number c, Term *ts) { \
|
||||
#define BEGIN_ERROR_CLASSES() \
|
||||
static Term mkerrorct(yap_error_class_number c, Term *ts) { \
|
||||
switch (c) {
|
||||
|
||||
#define ECLASS(CL, A, B) \
|
||||
case CL: \
|
||||
if (A == 0) \
|
||||
return MkAtomTerm(Yap_LookupAtom(A)); \
|
||||
else { \
|
||||
return Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom(A), B), B, ts); \
|
||||
}
|
||||
#define ECLASS(CL, A, B) \
|
||||
case CL: \
|
||||
if (A == 0) \
|
||||
return MkAtomTerm(Yap_LookupAtom(A)); \
|
||||
else { \
|
||||
return Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom(A), B), B, ts); \
|
||||
}
|
||||
|
||||
#define END_ERROR_CLASSES() \
|
||||
} \
|
||||
#define END_ERROR_CLASSES() \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BEGIN_ERRORS() \
|
||||
static Term mkerrort(yap_error_number e, Term *ts) { \
|
||||
#define BEGIN_ERRORS() \
|
||||
static Term mkerrort(yap_error_number e, Term *ts) { \
|
||||
switch (e) {
|
||||
|
||||
#define E0(A, B) \
|
||||
case A: \
|
||||
return mkerrorct(B, ts);
|
||||
#define E0(A, B) \
|
||||
case A: \
|
||||
return mkerrorct(B, ts);
|
||||
|
||||
#define E(A, B, C) \
|
||||
case A: \
|
||||
ts -= 1; \
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \
|
||||
return mkerrorct(B, ts);
|
||||
#define E(A, B, C) \
|
||||
case A: \
|
||||
ts -= 1; \
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \
|
||||
return mkerrorct(B, ts);
|
||||
|
||||
#define E2(A, B, C, D) \
|
||||
case A: \
|
||||
ts -= 2; \
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \
|
||||
ts[1] = MkAtomTerm(Yap_LookupAtom(D)); \
|
||||
return mkerrorct(B, ts);
|
||||
#define E2(A, B, C, D) \
|
||||
case A: \
|
||||
ts -= 2; \
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \
|
||||
ts[1] = MkAtomTerm(Yap_LookupAtom(D)); \
|
||||
return mkerrorct(B, ts);
|
||||
|
||||
#define END_ERRORS() \
|
||||
} \
|
||||
}
|
||||
#define END_ERRORS() \
|
||||
} \
|
||||
}
|
||||
|
||||
#include "YapErrors.h"
|
||||
|
||||
/**
|
||||
* @brief Yap_Error
|
||||
* @brief Yap_Error
|
||||
* This function handles errors in the C code. Check errors.yap for the
|
||||
*corresponding Prolog code.
|
||||
*
|
||||
@ -378,7 +378,7 @@ case A: \
|
||||
yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
yap_error_number type, Term where, ...) {
|
||||
CACHE_REGS
|
||||
va_list ap;
|
||||
va_list ap;
|
||||
CELL nt[3];
|
||||
Functor fun;
|
||||
bool serious;
|
||||
@ -488,16 +488,16 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
return P;
|
||||
}
|
||||
switch (type) {
|
||||
case SYSTEM_ERROR_INTERNAL: {
|
||||
fprintf(stderr, "%% Internal YAP Error: %s exiting....\n", tmpbuf);
|
||||
serious = TRUE;
|
||||
if (LOCAL_PrologMode & BootMode) {
|
||||
case SYSTEM_ERROR_INTERNAL: {
|
||||
fprintf(stderr, "%% Internal YAP Error: %s exiting....\n", tmpbuf);
|
||||
serious = TRUE;
|
||||
if (LOCAL_PrologMode & BootMode) {
|
||||
fprintf(stderr, "%% YAP crashed while booting %s\n", tmpbuf);
|
||||
} else {
|
||||
Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, YAP_BUF_SIZE);
|
||||
if (tmpbuf[0]) {
|
||||
fprintf(stderr, "%% Bug found while executing %s\n", tmpbuf);
|
||||
}
|
||||
fprintf(stderr, "%% Bug found while executing %s\n", tmpbuf);
|
||||
}
|
||||
#if HAVE_BACKTRACE
|
||||
void *callstack[256];
|
||||
int i;
|
||||
@ -505,7 +505,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
char** strs = backtrace_symbols(callstack, frames);
|
||||
fprintf(stderr, "Execution stack:\n");
|
||||
for (i = 0; i < frames; ++i) {
|
||||
fprintf(stderr, " %s\n", strs[i]);
|
||||
fprintf(stderr, " %s\n", strs[i]);
|
||||
|
||||
}
|
||||
free(strs);
|
||||
@ -553,6 +553,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
return (P);
|
||||
default: {
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
Term ts[3];
|
||||
ts[2] = where;
|
||||
nt[0] = mkerrort(type, ts + 2);
|
||||
@ -560,7 +561,8 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
if (type != ABORT_EVENT) {
|
||||
Term location;
|
||||
|
||||
@ -577,57 +579,56 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
}
|
||||
nt[1] = TermNil;
|
||||
switch (type) {
|
||||
case RESOURCE_ERROR_HEAP:
|
||||
case RESOURCE_ERROR_STACK:
|
||||
case RESOURCE_ERROR_TRAIL:
|
||||
comment = MkAtomTerm(Yap_LookupAtom(tmpbuf));
|
||||
default:
|
||||
if (comment != TermNil)
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("i")), comment),
|
||||
nt[1]);
|
||||
if (file && function) {
|
||||
Term ts[3], t3;
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(file));
|
||||
ts[1] = MkIntegerTerm(lineno);
|
||||
ts[2] = MkAtomTerm(Yap_LookupAtom(function));
|
||||
t3 = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("c"), 3), 3, ts);
|
||||
nt[1] =
|
||||
MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("c")), t3), nt[1]);
|
||||
}
|
||||
if ((location = Yap_pc_location(P, B, ENV)) != TermNil) {
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("p")), location),
|
||||
nt[1]);
|
||||
}
|
||||
if ((location = Yap_env_location(CP, B, ENV, 0)) != TermNil) {
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("e")), location),
|
||||
nt[1]);
|
||||
}
|
||||
case RESOURCE_ERROR_HEAP:
|
||||
case RESOURCE_ERROR_STACK:
|
||||
case RESOURCE_ERROR_TRAIL:
|
||||
comment = MkAtomTerm(Yap_LookupAtom(tmpbuf));
|
||||
default:
|
||||
if (comment != TermNil)
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("i")), comment),
|
||||
nt[1]);
|
||||
if (file && function) {
|
||||
Term ts[3], t3;
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom(file));
|
||||
ts[1] = MkIntegerTerm(lineno);
|
||||
ts[2] = MkAtomTerm(Yap_LookupAtom(function));
|
||||
t3 = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("c"), 3), 3, ts);
|
||||
nt[1] =
|
||||
MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("c")), t3), nt[1]);
|
||||
}
|
||||
if ((location = Yap_pc_location(P, B, ENV)) != TermNil) {
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("p")), location),
|
||||
nt[1]);
|
||||
}
|
||||
if ((location = Yap_env_location(CP, B, ENV, 0)) != TermNil) {
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("e")), location),
|
||||
nt[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* disable active signals at this point */
|
||||
LOCAL_Signals = 0;
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
/* disable active signals at this point */
|
||||
LOCAL_Signals = 0;
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
#if DEBUG
|
||||
// DumpActiveGoals( PASS_REGS1 );
|
||||
// DumpActiveGoals( PASS_REGS1 );
|
||||
#endif
|
||||
/* wait if we we are in user code,
|
||||
/* wait if we we are in user code,
|
||||
it's up to her to decide */
|
||||
fun = FunctorError;
|
||||
fun = FunctorError;
|
||||
error_t = Yap_MkApplTerm(fun, 2, nt);
|
||||
|
||||
if (type == ABORT_EVENT) {
|
||||
error_t = MkAtomTerm(AtomDAbort);
|
||||
} else {
|
||||
error_t = Yap_MkApplTerm(fun, 2, nt);
|
||||
}
|
||||
Yap_JumpToEnv(error_t);
|
||||
P = (yamop *)FAILCODE;
|
||||
if (type == ABORT_EVENT) {
|
||||
error_t = MkAtomTerm(AtomDAbort);
|
||||
} else {
|
||||
error_t = Yap_MkApplTerm(fun, 2, nt);
|
||||
}
|
||||
Yap_JumpToEnv(error_t);
|
||||
P = (yamop *)FAILCODE;
|
||||
|
||||
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
return P;
|
||||
}
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
return P;
|
||||
}
|
||||
|
||||
static Int
|
||||
is_boolean( USES_REGS1 )
|
||||
@ -728,7 +729,7 @@ void
|
||||
Yap_InitErrorPreds( void )
|
||||
{
|
||||
CACHE_REGS
|
||||
Yap_InitCPred("is_boolean", 2, is_boolean, TestPredFlag);
|
||||
Yap_InitCPred("is_boolean", 2, is_boolean, TestPredFlag);
|
||||
Yap_InitCPred("is_callable", 2, is_callable, TestPredFlag);
|
||||
Yap_InitCPred("is_atom", 2, is_atom, TestPredFlag);
|
||||
Yap_InitCPred("is_predicate_indicator", 2, is_predicate_indicator, TestPredFlag);
|
||||
|
@ -1341,6 +1341,7 @@ do_prolog_flag_property(Term tflag,
|
||||
Term modt = CurrentModule;
|
||||
tflag = Yap_YapStripModule(tflag, &modt);
|
||||
} else {
|
||||
free(args);
|
||||
Yap_Error(TYPE_ERROR_ATOM, tflag, "yap_flag/2");
|
||||
return (FALSE);
|
||||
}
|
||||
@ -1397,6 +1398,7 @@ do_prolog_flag_property(Term tflag,
|
||||
}
|
||||
}
|
||||
// UNLOCK(GLOBAL_Prolog_Flag[sno].prolog_flaglock);
|
||||
free(args);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1501,8 +1503,10 @@ static Int do_create_prolog_flag(USES_REGS1) {
|
||||
fv = GetFlagProp(AtomOfTerm(tflag));
|
||||
if (fv) {
|
||||
if (args[PROLOG_FLAG_PROPERTY_KEEP].used &&
|
||||
args[PROLOG_FLAG_PROPERTY_KEEP].tvalue == TermTrue)
|
||||
args[PROLOG_FLAG_PROPERTY_KEEP].tvalue == TermTrue) {
|
||||
free(args);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
newFlag(tflag, tval);
|
||||
fv = GetFlagProp(AtomOfTerm(tflag));
|
||||
@ -1530,6 +1534,7 @@ static Int do_create_prolog_flag(USES_REGS1) {
|
||||
fv->type = isground;
|
||||
} break;
|
||||
case PROLOG_FLAG_PROPERTY_SCOPE:
|
||||
free(args);
|
||||
return false;
|
||||
case PROLOG_FLAG_PROPERTY_END:
|
||||
break;
|
||||
@ -1537,6 +1542,7 @@ static Int do_create_prolog_flag(USES_REGS1) {
|
||||
}
|
||||
}
|
||||
// UNLOCK(GLOBAL_Prolog_Flag[sno].prolog_flaglock);
|
||||
free(args);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
1
H/ATOMS
1
H/ATOMS
@ -137,6 +137,7 @@ A ExecuteInMod F "$execute_in_mod"
|
||||
A ExecuteWithin F "$execute_within"
|
||||
A ExecuteWoMod F "$execute_wo_mod"
|
||||
A Exist N "exist"
|
||||
A Exists N "exists"
|
||||
A Exit N "exit"
|
||||
A ExistenceError N "existence_error"
|
||||
A ExoClause F "$exo_clause"
|
||||
|
@ -132,6 +132,7 @@
|
||||
AtomExecuteWithin = Yap_FullLookupAtom("$execute_within"); TermExecuteWithin = MkAtomTerm(AtomExecuteWithin);
|
||||
AtomExecuteWoMod = Yap_FullLookupAtom("$execute_wo_mod"); TermExecuteWoMod = MkAtomTerm(AtomExecuteWoMod);
|
||||
AtomExist = Yap_LookupAtom("exist"); TermExist = MkAtomTerm(AtomExist);
|
||||
AtomExists = Yap_LookupAtom("exists"); TermExists = MkAtomTerm(AtomExists);
|
||||
AtomExit = Yap_LookupAtom("exit"); TermExit = MkAtomTerm(AtomExit);
|
||||
AtomExistenceError = Yap_LookupAtom("existence_error"); TermExistenceError = MkAtomTerm(AtomExistenceError);
|
||||
AtomExoClause = Yap_FullLookupAtom("$exo_clause"); TermExoClause = MkAtomTerm(AtomExoClause);
|
||||
@ -377,6 +378,7 @@
|
||||
AtomSystem = Yap_LookupAtom("system"); TermSystem = MkAtomTerm(AtomSystem);
|
||||
AtomSystemError = Yap_LookupAtom("SYSTEM_ERROR_INTERNAL"); TermSystemError = MkAtomTerm(AtomSystemError);
|
||||
AtomSystemLibraryDir = Yap_LookupAtom("system_library_directory"); TermSystemLibraryDir = MkAtomTerm(AtomSystemLibraryDir);
|
||||
AtomT = Yap_LookupAtom("t"); TermT = MkAtomTerm(AtomT);
|
||||
AtomTerm = Yap_LookupAtom("term"); TermTerm = MkAtomTerm(AtomTerm);
|
||||
AtomTermExpansion = Yap_LookupAtom("term_expansion"); TermTermExpansion = MkAtomTerm(AtomTermExpansion);
|
||||
AtomTerms = Yap_LookupAtom("terms"); TermTerms = MkAtomTerm(AtomTerms);
|
||||
@ -394,6 +396,7 @@
|
||||
AtomTrue = Yap_LookupAtom("true"); TermTrue = MkAtomTerm(AtomTrue);
|
||||
AtomTty = Yap_LookupAtom("tty"); TermTty = MkAtomTerm(AtomTty);
|
||||
AtomTtys = Yap_LookupAtom("ttys"); TermTtys = MkAtomTerm(AtomTtys);
|
||||
AtomTuple = Yap_LookupAtom("tuple"); TermTuple = MkAtomTerm(AtomTuple);
|
||||
AtomTxt = Yap_LookupAtom("txt"); TermTxt = MkAtomTerm(AtomTxt);
|
||||
AtomTypeError = Yap_LookupAtom("type_error"); TermTypeError = MkAtomTerm(AtomTypeError);
|
||||
AtomUndefined = Yap_LookupAtom("undefined"); TermUndefined = MkAtomTerm(AtomUndefined);
|
||||
|
@ -132,6 +132,7 @@
|
||||
AtomExecuteWithin = AtomAdjust(AtomExecuteWithin); TermExecuteWithin = MkAtomTerm(AtomExecuteWithin);
|
||||
AtomExecuteWoMod = AtomAdjust(AtomExecuteWoMod); TermExecuteWoMod = MkAtomTerm(AtomExecuteWoMod);
|
||||
AtomExist = AtomAdjust(AtomExist); TermExist = MkAtomTerm(AtomExist);
|
||||
AtomExists = AtomAdjust(AtomExists); TermExists = MkAtomTerm(AtomExists);
|
||||
AtomExit = AtomAdjust(AtomExit); TermExit = MkAtomTerm(AtomExit);
|
||||
AtomExistenceError = AtomAdjust(AtomExistenceError); TermExistenceError = MkAtomTerm(AtomExistenceError);
|
||||
AtomExoClause = AtomAdjust(AtomExoClause); TermExoClause = MkAtomTerm(AtomExoClause);
|
||||
@ -377,6 +378,7 @@
|
||||
AtomSystem = AtomAdjust(AtomSystem); TermSystem = MkAtomTerm(AtomSystem);
|
||||
AtomSystemError = AtomAdjust(AtomSystemError); TermSystemError = MkAtomTerm(AtomSystemError);
|
||||
AtomSystemLibraryDir = AtomAdjust(AtomSystemLibraryDir); TermSystemLibraryDir = MkAtomTerm(AtomSystemLibraryDir);
|
||||
AtomT = AtomAdjust(AtomT); TermT = MkAtomTerm(AtomT);
|
||||
AtomTerm = AtomAdjust(AtomTerm); TermTerm = MkAtomTerm(AtomTerm);
|
||||
AtomTermExpansion = AtomAdjust(AtomTermExpansion); TermTermExpansion = MkAtomTerm(AtomTermExpansion);
|
||||
AtomTerms = AtomAdjust(AtomTerms); TermTerms = MkAtomTerm(AtomTerms);
|
||||
@ -394,6 +396,7 @@
|
||||
AtomTrue = AtomAdjust(AtomTrue); TermTrue = MkAtomTerm(AtomTrue);
|
||||
AtomTty = AtomAdjust(AtomTty); TermTty = MkAtomTerm(AtomTty);
|
||||
AtomTtys = AtomAdjust(AtomTtys); TermTtys = MkAtomTerm(AtomTtys);
|
||||
AtomTuple = AtomAdjust(AtomTuple); TermTuple = MkAtomTerm(AtomTuple);
|
||||
AtomTxt = AtomAdjust(AtomTxt); TermTxt = MkAtomTerm(AtomTxt);
|
||||
AtomTypeError = AtomAdjust(AtomTypeError); TermTypeError = MkAtomTerm(AtomTypeError);
|
||||
AtomUndefined = AtomAdjust(AtomUndefined); TermUndefined = MkAtomTerm(AtomUndefined);
|
||||
|
@ -132,6 +132,7 @@ Atom AtomExecuteInMod; Term TermExecuteInMod;
|
||||
Atom AtomExecuteWithin; Term TermExecuteWithin;
|
||||
Atom AtomExecuteWoMod; Term TermExecuteWoMod;
|
||||
Atom AtomExist; Term TermExist;
|
||||
Atom AtomExists; Term TermExists;
|
||||
Atom AtomExit; Term TermExit;
|
||||
Atom AtomExistenceError; Term TermExistenceError;
|
||||
Atom AtomExoClause; Term TermExoClause;
|
||||
@ -377,6 +378,7 @@ Atom AtomSyntaxErrorHandler; Term TermSyntaxErrorHandler;
|
||||
Atom AtomSystem; Term TermSystem;
|
||||
Atom AtomSystemError; Term TermSystemError;
|
||||
Atom AtomSystemLibraryDir; Term TermSystemLibraryDir;
|
||||
Atom AtomT; Term TermT;
|
||||
Atom AtomTerm; Term TermTerm;
|
||||
Atom AtomTermExpansion; Term TermTermExpansion;
|
||||
Atom AtomTerms; Term TermTerms;
|
||||
@ -394,6 +396,7 @@ Atom AtomTrail;
|
||||
Atom AtomTrue; Term TermTrue;
|
||||
Atom AtomTty; Term TermTty;
|
||||
Atom AtomTtys; Term TermTtys;
|
||||
Atom AtomTuple; Term TermTuple;
|
||||
Atom AtomTxt; Term TermTxt;
|
||||
Atom AtomTypeError; Term TermTypeError;
|
||||
Atom AtomUndefined; Term TermUndefined;
|
||||
|
@ -138,7 +138,6 @@ restart:
|
||||
#endif
|
||||
LOCAL_PrologMode |= ConsoleGetcMode;
|
||||
ch = fgetc(s->file);
|
||||
printf("got %d\n", ch);
|
||||
#if HAVE_SIGINTERRUPT
|
||||
siginterrupt(SIGINT, FALSE);
|
||||
#endif
|
||||
|
12
os/files.c
12
os/files.c
@ -374,8 +374,10 @@ static Int access_file(USES_REGS1) {
|
||||
{
|
||||
int mode;
|
||||
|
||||
if (atmode == AtomExist)
|
||||
mode = 00;
|
||||
if (atmode == AtomExist)
|
||||
mode = 00;
|
||||
else if (atmode == AtomExists)
|
||||
mode = 00;
|
||||
else if (atmode == AtomWrite)
|
||||
mode = 02;
|
||||
else if (atmode == AtomRead)
|
||||
@ -400,8 +402,10 @@ static Int access_file(USES_REGS1) {
|
||||
{
|
||||
int mode;
|
||||
|
||||
if (atmode == AtomExist)
|
||||
mode = F_OK;
|
||||
if (atmode == AtomExist)
|
||||
mode = F_OK;
|
||||
else if (atmode == AtomExists)
|
||||
mode = F_OK;
|
||||
else if (atmode == AtomWrite)
|
||||
mode = W_OK;
|
||||
else if (atmode == AtomRead)
|
||||
|
59
os/format.c
59
os/format.c
@ -351,7 +351,7 @@ static bool fill_pads(int sno, int sno0, int total, format_info *fg USES_REGS) {
|
||||
/* last gap??*/
|
||||
if (padi-fg->gap == fg->gapi) {
|
||||
for (j=0; j < fill_space; j++)
|
||||
f_putc(sno0, padi->filler);
|
||||
f_putc(sno0, (padi-1)->filler);
|
||||
}
|
||||
|
||||
}
|
||||
@ -483,8 +483,10 @@ static Int format_copy_args(Term args, Term *targs, Int tsz) {
|
||||
static void
|
||||
|
||||
format_clean_up(int sno, int sno0, format_info *finf, const char *fstr, const Term *targs) {
|
||||
format_synch( sno, sno0, finf);
|
||||
Yap_CloseStream(sno);
|
||||
if (sno > 0) {
|
||||
format_synch( sno, sno0, finf);
|
||||
Yap_CloseStream(sno);
|
||||
}
|
||||
if (fstr) {
|
||||
Yap_FreeAtomSpace((void *)fstr);
|
||||
}
|
||||
@ -532,6 +534,7 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
volatile int old_pos;
|
||||
format_info finfo;
|
||||
Term fmod = CurrentModule;
|
||||
bool alloc_fstr = false;
|
||||
|
||||
|
||||
finfo.format_error = FALSE;
|
||||
@ -571,11 +574,16 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
fstr = fptr = fstr0 = Yap_AllocAtomSpace(sz * sizeof(char));
|
||||
if ((fr = copy_format_string(tail, fstr0, sz)) == fst_ok)
|
||||
break;
|
||||
if (fr == fst_error)
|
||||
if (fr == fst_error) {
|
||||
Yap_FreeCodeSpace(fstr0);
|
||||
fstr = NULL;
|
||||
return false;
|
||||
}
|
||||
sz += 256;
|
||||
Yap_FreeCodeSpace(fstr0);
|
||||
Yap_FreeCodeSpace(fstr0);
|
||||
fstr = NULL;
|
||||
} while (TRUE);
|
||||
alloc_fstr = true;
|
||||
} else if (IsAtomTerm(tail)) {
|
||||
fstr = fptr = RepAtom(AtomOfTerm(tail))->StrOfAE;
|
||||
} else if (IsStringTerm(tail)) {
|
||||
@ -613,7 +621,7 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
if (tnum == FORMAT_COPY_ARGS_ERROR)
|
||||
return FALSE;
|
||||
else if (tnum == FORMAT_COPY_ARGS_OVERFLOW) {
|
||||
if (mytargs != targs) {
|
||||
if (mytargs != targs) {
|
||||
Yap_FreeCodeSpace((char *)targs);
|
||||
}
|
||||
tsz += 16;
|
||||
@ -635,12 +643,21 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
finfo.format_error = false;
|
||||
finfo.gapi = 0;
|
||||
sno0 = sno;
|
||||
sno = Yap_OpenBufWriteStream(PASS_REGS1);
|
||||
finfo.format_error = false;
|
||||
finfo.gapi = 0;
|
||||
finfo.phys_start = 0;
|
||||
finfo.lstart = 0;
|
||||
f_putc = GLOBAL_Stream[sno].stream_wputc;
|
||||
sno = Yap_OpenBufWriteStream(PASS_REGS1);
|
||||
if (sno == -1) {
|
||||
if (!alloc_fstr)
|
||||
fstr = NULL;
|
||||
if (mytargs == targs) {
|
||||
targs = NULL;
|
||||
}
|
||||
format_clean_up(sno, sno0, &finfo, (char *)fstr, targs);
|
||||
return false;
|
||||
}
|
||||
while ((ch = *fptr++)) {
|
||||
Term t = TermNil;
|
||||
int has_repeats = false;
|
||||
@ -961,8 +978,15 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
args = Yap_GetFromSlot(sl);
|
||||
if (Yap_HasException())
|
||||
goto ex_handler;
|
||||
if (!res)
|
||||
if (!res) {
|
||||
if (!alloc_fstr)
|
||||
fstr = NULL;
|
||||
if (mytargs == targs) {
|
||||
targs = NULL;
|
||||
}
|
||||
format_clean_up(sno, sno0, &finfo, (char *)fstr, targs);
|
||||
return FALSE;
|
||||
}
|
||||
ts = Yap_GetFromSlot(sl2);
|
||||
Yap_CloseSlots(sl0);
|
||||
if (!format_print_str(sno, repeats, has_repeats, ts, f_putc)) {
|
||||
@ -993,7 +1017,12 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
if (GLOBAL_Stream[sno].status & InMemory_Stream_f) {
|
||||
GLOBAL_Stream[sno].u.mem_string.error_handler = old_handler;
|
||||
}
|
||||
format_clean_up(sno, sno0, &finfo, (char *)fstr, targs);
|
||||
if (!alloc_fstr)
|
||||
fstr = NULL;
|
||||
if (mytargs == targs) {
|
||||
targs = NULL;
|
||||
}
|
||||
format_clean_up(sno, sno0, &finfo, (char *)fstr, targs);
|
||||
Yap_RaiseException();
|
||||
return false;
|
||||
}
|
||||
@ -1109,7 +1138,12 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
if (GLOBAL_Stream[sno].status & InMemory_Stream_f) {
|
||||
GLOBAL_Stream[sno].u.mem_string.error_handler = old_handler;
|
||||
}
|
||||
format_clean_up(sno, sno0, &finfo, fstr, targs);
|
||||
if (!alloc_fstr)
|
||||
fstr = NULL;
|
||||
if (mytargs == targs) {
|
||||
targs = NULL;
|
||||
}
|
||||
format_clean_up(sno, sno0, &finfo, fstr, targs);
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
return FALSE;
|
||||
}
|
||||
@ -1132,6 +1166,11 @@ static Int doformat(volatile Term otail, volatile Term oargs,
|
||||
if (GLOBAL_Stream[sno].status & InMemory_Stream_f) {
|
||||
GLOBAL_Stream[sno].u.mem_string.error_handler = old_handler;
|
||||
}
|
||||
if (!alloc_fstr)
|
||||
fstr = NULL;
|
||||
if (mytargs == targs) {
|
||||
targs = NULL;
|
||||
}
|
||||
format_clean_up(sno, sno0, &finfo, fstr, targs);
|
||||
return (TRUE);
|
||||
}
|
||||
|
14
os/iopreds.c
14
os/iopreds.c
@ -1194,16 +1194,20 @@ do_open(Term file_name, Term t2,
|
||||
}
|
||||
/* done */
|
||||
sno = GetFreeStreamD();
|
||||
if (sno < 0)
|
||||
if (sno < 0) {
|
||||
free(args);
|
||||
return PlIOError(RESOURCE_ERROR_MAX_STREAMS, TermNil, "open/3");
|
||||
}
|
||||
st = &GLOBAL_Stream[sno];
|
||||
st->user_name = file_name;
|
||||
flags = s;
|
||||
// user requested encoding?
|
||||
if (args[OPEN_ALIAS].used) {
|
||||
Atom al = AtomOfTerm(args[OPEN_ALIAS].tvalue);
|
||||
if (!Yap_AddAlias(al, sno))
|
||||
if (!Yap_AddAlias(al, sno)) {
|
||||
free(args);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (args[OPEN_ENCODING].used) {
|
||||
tenc = args[OPEN_ENCODING].tvalue;
|
||||
@ -1277,10 +1281,11 @@ do_open(Term file_name, Term t2,
|
||||
free((void *)fname);
|
||||
fname = LOCAL_FileNameBuf;
|
||||
UNLOCK(st->streamlock);
|
||||
if (errno == ENOENT)
|
||||
if (errno == ENOENT) {
|
||||
free(args);
|
||||
return (PlIOError(EXISTENCE_ERROR_SOURCE_SINK, file_name, "%s: %s", fname,
|
||||
strerror(errno)));
|
||||
else {
|
||||
} else {
|
||||
return (PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, file_name, "%s: %s",
|
||||
fname, strerror(errno)));
|
||||
}
|
||||
@ -1310,6 +1315,7 @@ do_open(Term file_name, Term t2,
|
||||
if (script)
|
||||
open_header(sno, open_mode);
|
||||
|
||||
free(args);
|
||||
UNLOCK(st->streamlock);
|
||||
{
|
||||
Term t = Yap_MkStream(sno);
|
||||
|
16
os/streams.c
16
os/streams.c
@ -670,6 +670,7 @@ static Int cont_stream_property(USES_REGS1) { /* current_stream */
|
||||
// done
|
||||
det = (p == STREAM_PROPERTY_END);
|
||||
}
|
||||
free( args );
|
||||
if (rc) {
|
||||
if (det)
|
||||
cut_succeed();
|
||||
@ -720,9 +721,11 @@ static Int stream_property(USES_REGS1) { /* Init current_stream */
|
||||
}
|
||||
if (do_stream_property(i, args PASS_REGS)) {
|
||||
UNLOCK(GLOBAL_Stream[i].streamlock);
|
||||
free( args );
|
||||
cut_succeed();
|
||||
} else {
|
||||
UNLOCK(GLOBAL_Stream[i].streamlock);
|
||||
free( args );
|
||||
cut_fail();
|
||||
}
|
||||
} else {
|
||||
@ -912,17 +915,6 @@ static void CloseStream(int sno) {
|
||||
close(GLOBAL_Stream[sno].u.pipe.fd);
|
||||
} else if (GLOBAL_Stream[sno].status & (InMemory_Stream_f)) {
|
||||
Yap_CloseMemoryStream(sno);
|
||||
if (GLOBAL_Stream[sno].file == NULL) {
|
||||
char *s = GLOBAL_Stream[sno].u.mem_string.buf;
|
||||
if (s == LOCAL_FileNameBuf ||
|
||||
s == LOCAL_FileNameBuf2)
|
||||
return;
|
||||
if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_CODE)
|
||||
Yap_FreeAtomSpace(s);
|
||||
else if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_MALLOC) {
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
GLOBAL_Stream[sno].status = Free_Stream_f;
|
||||
Yap_DeleteAliases(sno);
|
||||
@ -1026,7 +1018,7 @@ static Int set_output(USES_REGS1) { /* '$show_stream_position'(+Stream,Pos) */
|
||||
static Int p_user_file_name(USES_REGS1) {
|
||||
Term tout;
|
||||
int sno =
|
||||
Yap_CheckStream(ARG1, Input_Stream_f | Output_Stream_f | Append_Stream_f,
|
||||
Yap_CheckStream(ARG1, Input_Stream_f | Output_Stream_f | Append_Stream_f,
|
||||
"user_file_name/2");
|
||||
if (sno < 0)
|
||||
return (FALSE);
|
||||
|
@ -290,11 +290,14 @@ static Int write_term2(USES_REGS1) {
|
||||
}
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
int output_stream = LOCAL_c_output_stream;
|
||||
if (output_stream == -1)
|
||||
if (output_stream == -1) {
|
||||
free( args );
|
||||
output_stream = 1;
|
||||
}
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term(output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -313,11 +316,14 @@ static Int write_term3(USES_REGS1) {
|
||||
return false;
|
||||
}
|
||||
int output_stream = Yap_CheckTextStream(ARG1, Output_Stream_f, "write/2");
|
||||
if (output_stream < 0)
|
||||
if (output_stream < 0) {
|
||||
free( args );
|
||||
return false;
|
||||
}
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
write_term(output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -346,6 +352,7 @@ static Int write2(USES_REGS1) {
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
write_term(output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -372,6 +379,7 @@ static Int write1(USES_REGS1) {
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term(output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -400,6 +408,7 @@ static Int write_canonical1(USES_REGS1) {
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term(output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -418,8 +427,10 @@ static Int write_canonical(USES_REGS1) {
|
||||
return false;
|
||||
}
|
||||
int output_stream = Yap_CheckTextStream(ARG1, Output_Stream_f, "write/2");
|
||||
if (output_stream < 0)
|
||||
if (output_stream < 0) {
|
||||
free( args );
|
||||
return false;
|
||||
}
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
args[WRITE_IGNORE_OPS].used = true;
|
||||
args[WRITE_IGNORE_OPS].tvalue = TermTrue;
|
||||
@ -427,6 +438,7 @@ static Int write_canonical(USES_REGS1) {
|
||||
args[WRITE_QUOTED].tvalue = TermTrue;
|
||||
write_term(output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -446,15 +458,17 @@ static Int writeq1(USES_REGS1) {
|
||||
}
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
int output_stream = LOCAL_c_output_stream;
|
||||
if (output_stream == -1)
|
||||
if (output_stream == -1) {
|
||||
free( args );
|
||||
output_stream = 1;
|
||||
}
|
||||
args[WRITE_NUMBERVARS].used = true;
|
||||
args[WRITE_NUMBERVARS].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);
|
||||
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -473,8 +487,10 @@ static Int writeq(USES_REGS1) {
|
||||
return false;
|
||||
}
|
||||
int output_stream = Yap_CheckTextStream(ARG1, Output_Stream_f, "write/2");
|
||||
if (output_stream < 0)
|
||||
if (output_stream < 0) {
|
||||
free( args );
|
||||
return false;
|
||||
}
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
args[WRITE_NUMBERVARS].used = true;
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
@ -482,6 +498,7 @@ static Int writeq(USES_REGS1) {
|
||||
args[WRITE_QUOTED].tvalue = TermTrue;
|
||||
write_term(output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -501,8 +518,10 @@ static Int print1(USES_REGS1) {
|
||||
}
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
int output_stream = LOCAL_c_output_stream;
|
||||
if (output_stream == -1)
|
||||
if (output_stream == -1) {
|
||||
free( args );
|
||||
output_stream = 1;
|
||||
}
|
||||
args[WRITE_PORTRAY].used = true;
|
||||
args[WRITE_PORTRAY].tvalue = TermTrue;
|
||||
args[WRITE_NUMBERVARS].used = true;
|
||||
@ -510,6 +529,7 @@ static Int print1(USES_REGS1) {
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term(output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -528,8 +548,10 @@ static Int print(USES_REGS1) {
|
||||
return false;
|
||||
}
|
||||
int output_stream = Yap_CheckTextStream(ARG1, Output_Stream_f, "write/2");
|
||||
if (output_stream < 0)
|
||||
if (output_stream < 0) {
|
||||
free( args );
|
||||
return false;
|
||||
}
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
args[WRITE_PORTRAY].used = true;
|
||||
args[WRITE_PORTRAY].tvalue = TermTrue;
|
||||
@ -537,6 +559,7 @@ static Int print(USES_REGS1) {
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
write_term(output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -563,6 +586,7 @@ static Int writeln1(USES_REGS1) {
|
||||
LOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
write_term(output_stream, ARG1, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
@ -579,8 +603,10 @@ static Int writeln(USES_REGS1) {
|
||||
return false;
|
||||
}
|
||||
int output_stream = Yap_CheckTextStream(ARG1, Output_Stream_f, "writeln/2");
|
||||
if (output_stream < 0)
|
||||
return false;
|
||||
if (output_stream < 0) {
|
||||
free( args );
|
||||
return false;
|
||||
}
|
||||
yhandle_t mySlots = Yap_StartSlots();
|
||||
args[WRITE_NL].used = true;
|
||||
args[WRITE_NL].tvalue = TermTrue;
|
||||
@ -588,6 +614,7 @@ static Int writeln(USES_REGS1) {
|
||||
args[WRITE_NUMBERVARS].tvalue = TermTrue;
|
||||
write_term(output_stream, ARG2, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
|
||||
free( args );
|
||||
Yap_CloseSlots(mySlots);
|
||||
Yap_RaiseException();
|
||||
return (TRUE);
|
||||
|
@ -7,6 +7,7 @@ This package uses the library cudd, see http://vlsi.colorado.edu/~fabio/CUDD/
|
||||
for the relative license.
|
||||
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "config.h"
|
||||
#include "cudd_config.h"
|
||||
#if HAVE_CUDD_CUDDINT_H
|
||||
|
@ -155,8 +155,6 @@ jpl_tidy_iref_type_cache( Iref) :-
|
||||
%
|
||||
% finally, an attempt will be made to unify Result with the returned result
|
||||
|
||||
:- stop_low_level_trace.
|
||||
|
||||
jpl_call(X, Mspec, Params, R) :-
|
||||
( jpl_object_to_type(X, Type) % the usual case (goal fails safely if X is var or rubbish)
|
||||
-> Obj = X,
|
||||
|
@ -1718,7 +1718,7 @@ log_event( String, Args ) :-
|
||||
yap_flag(toplevel_prompt, P),
|
||||
atomic_concat(LF, PF),
|
||||
prompt1(PF),
|
||||
prompt(_,' '),
|
||||
prompt(_,' | '),
|
||||
'$ensure_prompting'.
|
||||
|
||||
/**
|
||||
|
@ -414,7 +414,7 @@ load_files(Files,Opts) :-
|
||||
(
|
||||
atom(M)
|
||||
->
|
||||
'$lf'(X, M, Call, TOpts)
|
||||
'$lf'(X, M, Call, TOpts)
|
||||
;
|
||||
'$do_error'(type_error(atom,M),Call)
|
||||
).
|
||||
@ -431,23 +431,23 @@ load_files(Files,Opts) :-
|
||||
b_setval('$user_source_file', user_input),
|
||||
'$do_lf'(Mod, user_input, user_input, user_input, TOpts).
|
||||
'$lf'(File, Mod, Call, TOpts) :-
|
||||
'$lf_opt'(stream, TOpts, Stream),
|
||||
b_setval('$user_source_file', File),
|
||||
( var(Stream) ->
|
||||
'$lf_opt'(stream, TOpts, Stream),
|
||||
b_setval('$user_source_file', File),
|
||||
( var(Stream) ->
|
||||
/* need_to_open_file */
|
||||
( '$full_filename'(File, Y, Call) -> true ; '$do_error'(existence_error(source_sink,File),Call) ),
|
||||
( open(Y, read, Stream) -> true ; '$do_error'(permission_error(input,stream,Y),Call) )
|
||||
( '$full_filename'(File, Y, Call) -> true ; '$do_error'(existence_error(source_sink,File),Call) ),
|
||||
( open(Y, read, Stream) -> true ; '$do_error'(permission_error(input,stream,Y),Call) )
|
||||
;
|
||||
stream_property(Stream, file_name(Y))
|
||||
), !,
|
||||
( file_size(Stream, Pos) -> true ; Pos = 0),
|
||||
'$set_lf_opt'('$source_pos', TOpts, Pos),
|
||||
'$lf_opt'(reexport, TOpts, Reexport),
|
||||
'$lf_opt'(if, TOpts, If),
|
||||
( var(If) -> If = true ; true ),
|
||||
'$lf_opt'(imports, TOpts, Imports),
|
||||
'$start_lf'(If, Mod, Stream, TOpts, File, Y, Reexport, Imports),
|
||||
close(Stream).
|
||||
stream_property(Stream, file_name(Y))
|
||||
), !,
|
||||
( file_size(Stream, Pos) -> true ; Pos = 0),
|
||||
'$set_lf_opt'('$source_pos', TOpts, Pos),
|
||||
'$lf_opt'(reexport, TOpts, Reexport),
|
||||
'$lf_opt'(if, TOpts, If),
|
||||
( var(If) -> If = true ; true ),
|
||||
'$lf_opt'(imports, TOpts, Imports),
|
||||
'$start_lf'(If, Mod, Stream, TOpts, File, Y, Reexport, Imports),
|
||||
close(Stream).
|
||||
|
||||
|
||||
'$start_lf'(not_loaded, Mod, _Stream, TOpts, UserFile, File, Reexport,Imports) :-
|
||||
@ -511,7 +511,7 @@ loaded, otherwise advertises the user about the existing name clashes
|
||||
are not public remain invisible.
|
||||
|
||||
When the files are not module files, ensure_loaded/1 loads them
|
||||
if they have not been loaded before, and does nothing otherwise.
|
||||
if they have not been loaded before, and does nothing otherwise.
|
||||
|
||||
_F_ must be a list containing the names of the files to load.
|
||||
*/
|
||||
@ -1396,8 +1396,7 @@ initialization(G0,OPT) :-
|
||||
expand_goal(G0, G),
|
||||
catch('$initialization'(G, OPT), Error, '$LoopError'( Error, consult ) ),
|
||||
fail.
|
||||
initialization(_G,_OPT) :-
|
||||
stop_low_level_trace.
|
||||
initialization(_G,_OPT).
|
||||
|
||||
'$initialization'(G,OPT) :-
|
||||
must_be_of_type(callable, G, initialization(G,OPT)),
|
||||
|
@ -2,7 +2,7 @@
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
@ -201,7 +201,6 @@ compose_message(Term, Level) -->
|
||||
caller( Term, Level ),
|
||||
extra_info( Term, Level ),
|
||||
!,
|
||||
% { start_low_level_trace },
|
||||
[nl,nl].
|
||||
compose_message(Term, Level) -->
|
||||
{ Level == error -> true ; Level == warning },
|
||||
|
Reference in New Issue
Block a user