Merge branch 'master' of github.com:vscosta/yap-6.3
This commit is contained in:
commit
9fcbfca1fa
@ -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);
|
||||
LOCAL_ConsultBase = new_cl + ((LOCAL_ConsultBase - LOCAL_ConsultLow)+InitialConsultCapacity);
|
||||
/* new consult pointer */
|
||||
LOCAL_ConsultSp = new_cs;
|
||||
LOCAL_ConsultSp = new_cl + ((LOCAL_ConsultSp - LOCAL_ConsultLow)+InitialConsultCapacity);
|
||||
/* new end of memory */
|
||||
LOCAL_ConsultLow = new_cl;
|
||||
}
|
||||
@ -1389,7 +1389,7 @@ 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) {
|
||||
if (LOCAL_ConsultSp <= LOCAL_ConsultLow + 6) {
|
||||
expand_consult();
|
||||
}
|
||||
--LOCAL_ConsultSp;
|
||||
@ -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,6 +2503,7 @@ static Term GetDBTerm(DBTerm *DBSP, int src USES_REGS) {
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
if (HR + NOf > ASP - EventFlag / sizeof(CELL)) {
|
||||
if (LOCAL_PrologMode & InErrorMode) {
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
if (HR + NOf > ASP)
|
||||
fprintf(stderr,
|
||||
"\n\n [ FATAL ERROR: No Stack for Error Handling ]\n");
|
||||
@ -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);
|
||||
|
@ -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);
|
||||
@ -561,6 +562,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
|
||||
|
||||
}
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
if (type != ABORT_EVENT) {
|
||||
Term location;
|
||||
|
||||
@ -607,7 +609,6 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
/* disable active signals at this point */
|
||||
LOCAL_Signals = 0;
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
#if DEBUG
|
||||
// DumpActiveGoals( PASS_REGS1 );
|
||||
#endif
|
||||
|
@ -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
|
||||
|
@ -376,6 +376,8 @@ static Int access_file(USES_REGS1) {
|
||||
|
||||
if (atmode == AtomExist)
|
||||
mode = 00;
|
||||
else if (atmode == AtomExists)
|
||||
mode = 00;
|
||||
else if (atmode == AtomWrite)
|
||||
mode = 02;
|
||||
else if (atmode == AtomRead)
|
||||
@ -402,6 +404,8 @@ static Int access_file(USES_REGS1) {
|
||||
|
||||
if (atmode == AtomExist)
|
||||
mode = F_OK;
|
||||
else if (atmode == AtomExists)
|
||||
mode = F_OK;
|
||||
else if (atmode == AtomWrite)
|
||||
mode = W_OK;
|
||||
else if (atmode == AtomRead)
|
||||
|
47
os/format.c
47
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) {
|
||||
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);
|
||||
fstr = NULL;
|
||||
} while (TRUE);
|
||||
alloc_fstr = true;
|
||||
} else if (IsAtomTerm(tail)) {
|
||||
fstr = fptr = RepAtom(AtomOfTerm(tail))->StrOfAE;
|
||||
} else if (IsStringTerm(tail)) {
|
||||
@ -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,6 +1017,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, (char *)fstr, targs);
|
||||
Yap_RaiseException();
|
||||
return false;
|
||||
@ -1109,6 +1138,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);
|
||||
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,17 +1194,21 @@ 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;
|
||||
s_encoding = RepAtom(AtomOfTerm(tenc))->StrOfAE;
|
||||
@ -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);
|
||||
|
14
os/streams.c
14
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);
|
||||
|
@ -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)
|
||||
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'.
|
||||
|
||||
/**
|
||||
|
@ -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)),
|
||||
|
@ -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