only evaluate lists with a single character.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2214 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2008-04-08 15:36:53 +00:00
parent 12e18227bb
commit 516a349aad
4 changed files with 24 additions and 9 deletions

View File

@ -108,6 +108,12 @@ Eval(Term t, E_ARGS)
}
}
} else if (IsPairTerm(t)) {
if (TailOfTerm(t) != TermNil) {
Yap_Error(TYPE_ERROR_EVALUABLE, t,
"string must contain a single character to be evaluated as an arithmetic expression");
P = (yamop *)FAILCODE;
RERROR();
}
return(Eval(HeadOfTerm(t), USE_E_ARGS));
} else if (IsIntTerm(t)) {
RINT(IntOfTerm(t));
@ -182,6 +188,12 @@ Yap_Eval(Term t, E_ARGS)
}
}
} else if (IsPairTerm(t)) {
if (TailOfTerm(t) != TermNil) {
Yap_Error(TYPE_ERROR_EVALUABLE, t,
"string must contain a single character to be evaluated as an arithmetic expression");
P = (yamop *)FAILCODE;
RERROR();
}
return(Eval(HeadOfTerm(t), USE_E_ARGS));
} else if (IsIntTerm(t)) {
RINT(IntOfTerm(t));

View File

@ -101,7 +101,6 @@ kill_thread_engine (int wid)
Yap_KillStacks(wid);
Yap_FreeCodeSpace((ADDR)(ThreadHandle[wid].tgoal));
Yap_heap_regs->wl[wid].active_signals = 0L;
pthread_mutex_lock(&(ThreadHandle[wid].tlock));
free(Yap_heap_regs->wl[wid].scratchpad.ptr);
free(ThreadHandle[wid].default_yaam_regs);
ThreadHandle[wid].current_yaam_regs = NULL;
@ -356,7 +355,6 @@ Yap_thread_detach_engine(int wid)
Int
Yap_thread_destroy_engine(int wid)
{
pthread_mutex_lock(&(ThreadHandle[wid].tlock));
if (ThreadHandle[wid].ref_count == 0) {
kill_thread_engine(wid);
return TRUE;
@ -382,6 +380,7 @@ p_thread_join(void)
UNLOCK(ThreadHandlesLock);
return FALSE;
}
pthread_mutex_lock(&(ThreadHandle[tid].tlock));
UNLOCK(ThreadHandlesLock);
/* make sure this lock is accessible */
if (pthread_join(ThreadHandle[tid].handle, NULL) < 0) {
@ -413,7 +412,6 @@ p_thread_detach(void)
}
ThreadHandle[tid].tdetach =
MkAtomTerm(AtomTrue);
pthread_mutex_unlock(&(ThreadHandle[tid].tlock));
return TRUE;
}
@ -670,9 +668,10 @@ p_thread_runtime(void)
}
static Int
p_thread_self_lock(void)
p_thread_unlock(void)
{ /* '$thread_self_lock' */
pthread_mutex_lock(&(ThreadHandle[worker_id].tlock));
Int wid = IntegerOfTerm(Deref(ARG1));
pthread_mutex_unlock(&(ThreadHandle[wid].tlock));
return TRUE;
}
@ -708,6 +707,7 @@ void Yap_InitThreadPreds(void)
Yap_InitCPred("$nof_threads_created", 1, p_nof_threads_created, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_sleep", 4, p_thread_sleep, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_runtime", 1, p_thread_runtime, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_unlock", 1, p_thread_unlock, SafePredFlag);
}
#else
@ -749,7 +749,7 @@ p_thread_self(void)
}
static Int
p_thread_self_lock(void)
p_thread_unlock(void)
{ /* '$thread_runtime'(+P) */
return TRUE;
}
@ -762,7 +762,7 @@ void Yap_InitThreadPreds(void)
Yap_InitCPred("$nof_threads", 1, p_nof_threads, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$nof_threads_created", 1, p_nof_threads_created, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_runtime", 1, p_thread_runtime, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$self_thread_lock", 0, p_thread_self_lock, SafePredFlag);
Yap_InitCPred("$thread_unlock", 1, p_thread_unlock, SafePredFlag);
}

View File

@ -3445,7 +3445,8 @@ the call.
@var{Char} is a lower-case letter.
@item lower(Upper)
@var{Char} is a lower-case version of Upper. Only true if @var{Char} is lowercase and Upper uppercase.
@var{Char} is a lower-case version of @var{Upper}. Only true if
@var{Char} is lowercase and @var{Upper} uppercase.
@item to_lower(Upper)
@var{Char} is a lower-case version of Upper. For non-letters, or letter without case, @var{Char} and Lower are the same. See also upcase_atom/2 and downcase_atom/2.

View File

@ -337,7 +337,8 @@ thread_detach(Id) :-
( recorded('$thread_exit_status', [Id0|_], _) ->
'$erase_thread_info'(Id0),
'$thread_destroy'(Id0)
; true
;
'$thread_unlock'(Id0)
).
thread_exit(Term) :-
@ -637,6 +638,7 @@ message_queue_destroy(Queue) :-
recorded('$queue',q(Queue,Mutex,Cond,_,QKey),R), !,
erase(R),
'$cond_destroy'(Cond),
write(Queue:Mutex),nl,
'$destroy_mutex'(Mutex),
'$unlock_mutex'(QMutex),
'$clean_mqueue'(QKey).