fix setof to use catch instead of trying to do its own thing;

fix unnecessary white lines when outputting solutions.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@788 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2003-02-24 11:01:01 +00:00
parent 540d9639cb
commit 51ea20683f
9 changed files with 48 additions and 79 deletions

View File

@@ -313,7 +313,7 @@ p_fdiv(Term t1, Term t2 E_ARGS)
{
Int i1 = IntegerOfTerm(t1);
Float f2 = mpz_get_d(Yap_BigIntOfTerm(t2));
RFLOAT(i1/f2);
RFLOAT(((Float)i1/f2));
}
#endif
default:

View File

@@ -113,8 +113,6 @@ typedef struct idb_queue
rwlock_t QRWLock; /* a simple lock to protect this entry */
#endif
DBRef FirstInQueue, LastInQueue;
Int age; /* the number of catches when we created the queue */
struct idb_queue *next, *prev;
} db_queue;
#define HashFieldMask ((CELL)0xffL)
@@ -4287,24 +4285,15 @@ p_init_queue(void)
db_queue *dbq;
Term t;
if (DBQueuesCache) {
dbq = DBQueuesCache;
DBQueuesCache = dbq->next;
} else {
while ((dbq = (db_queue *)AllocDBSpace(sizeof(db_queue))) == NULL) {
if (!Yap_growheap(FALSE)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}
while ((dbq = (db_queue *)AllocDBSpace(sizeof(db_queue))) == NULL) {
if (!Yap_growheap(FALSE)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}
dbq->id = FunctorDBRef;
dbq->Flags = DBClMask;
dbq->FirstInQueue = dbq->LastInQueue = NULL;
dbq->prev = NULL;
}
dbq->next = DBQueues;
DBQueues = dbq;
dbq->age = IntOfTerm(Yap_GetValue(AtomCatch));
dbq->id = FunctorDBRef;
dbq->Flags = DBClMask;
dbq->FirstInQueue = dbq->LastInQueue = NULL;
INIT_RWLOCK(dbq->QRWLock);
t = MkDBRefTerm((DBRef)dbq);
return(Yap_unify(ARG1, t));
@@ -4388,15 +4377,8 @@ p_dequeue(void)
WRITE_LOCK(father_key->QRWLock);
if ((cur_instance = father_key->FirstInQueue) == NULL) {
/* an empty queue automatically goes away */
if (father_key == DBQueues)
DBQueues = father_key->next;
else
father_key->prev->next = father_key->next;
if (father_key->next != NULL)
father_key->next->prev = father_key->prev;
father_key->next = DBQueuesCache;
DBQueuesCache = father_key;
WRITE_UNLOCK(father_key->QRWLock);
FreeDBSpace((char *)father_key);
return(FALSE);
} else {
Term TDB;
@@ -4418,30 +4400,6 @@ p_dequeue(void)
static Int
p_clean_queues(void)
{
Int myage = IntOfTerm(ARG1);
db_queue *ptr;
YAPEnterCriticalSection();
ptr = DBQueues;
while (ptr) {
if (ptr->age >= myage) {
DBRef cur_instance;
db_queue *optr = ptr;
while ((cur_instance = ptr->FirstInQueue)) {
/* release space for cur_instance */
ptr->FirstInQueue = (DBRef)(cur_instance->Parent);
ErasePendingRefs(cur_instance);
FreeDBSpace((char *) cur_instance);
}
ptr = ptr->next;
FreeDBSpace((char *) optr);
} else
break;
}
if (ptr)
ptr->prev = NULL;
DBQueues = ptr;
YAPLeaveCriticalSection();
return(TRUE);
}

View File

@@ -794,8 +794,6 @@ InitCodes(void)
*/
heap_regs->primitives_module = 0;
heap_regs->user_module = 1;
heap_regs->db_queues = NULL;
heap_regs->db_queues_cache = NULL;
heap_regs->atom_abol = Yap_LookupAtom("$abol");
AtomAltNot = Yap_LookupAtom("not");
heap_regs->atom_append = Yap_LookupAtom ("append");

View File

@@ -788,6 +788,18 @@ p_setprompt (void)
return (TRUE);
}
static Int
p_is_same_tty (void)
{ /* 'prompt(Atom) */
int sni = CheckStream (ARG1, Input_Stream_f, "put/2");
int sno = CheckStream (ARG2, Output_Stream_f, "put/2");
return (
(Stream[sni].status & Tty_Stream_f) &&
(Stream[sno].status & Tty_Stream_f) &&
is_same_tty(Stream[sno].u.file.file,Stream[sni].u.file.file)
);
}
static Int
p_prompt (void)
{ /* prompt(Old,New) */
@@ -5071,6 +5083,7 @@ Yap_InitIOPreds(void)
Yap_InitCPred ("current_input", 1, p_current_input, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("current_output", 1, p_current_output, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("prompt", 1, p_setprompt, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$is_same_tty", 2, p_is_same_tty, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("prompt", 2, p_prompt, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("always_prompt_user", 0, p_always_prompt_user, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("write_depth", 2, p_write_depth, SafePredFlag|SyncPredFlag);

View File

@@ -457,7 +457,7 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted
if (ch - '0' >= base)
return (MkIntegerTerm(val));
val = val * base + ch - '0';
if (oval >= val && oval != 0) /* overflow */
if (val/base != oval || val -oval*base != ch-'0') /* overflow */
has_overflow = (has_overflow || TRUE);
ch = Nxtch(inp_stream);
}