mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 01:00:20 +02:00
Don't use C operators == and != to compare SCM values.
This commit is contained in:
parent
91163914cf
commit
fbd485ba49
8 changed files with 52 additions and 28 deletions
|
@ -1,3 +1,27 @@
|
||||||
|
2000-03-29 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||||
|
|
||||||
|
* alist.c (scm_sloppy_assq, scm_assq), eq.c (scm_eq_p, scm_eqv_p,
|
||||||
|
scm_equal_p), list.c (scm_ilength, scm_last_pair, scm_reverse,
|
||||||
|
scm_sloppy_memq, scm_delq_x, scm_delq1_x), tags.h (SCM_UNBNDP):
|
||||||
|
Don't use C operators == and != to compare SCM values, use
|
||||||
|
SCM_EQ_P instead.
|
||||||
|
|
||||||
|
* boolean.c (scm_boolean_p): Use SCM_BOOLP to determine whether a
|
||||||
|
SCM value is equal to #t or #f.
|
||||||
|
|
||||||
|
* eq.c (scm_eqv_p, scm_equal_p): Don't use SCM_CAR to access the
|
||||||
|
cell type entry of non immediate objects of unknown type. Use
|
||||||
|
SCM_CELL_TYPE instead.
|
||||||
|
|
||||||
|
* gh_data.c (gh_scm2bool, gh_module_lookup), list.c
|
||||||
|
(scm_sloppy_memv, scm_sloppy_member, scm_delv_x, scm_delete_x,
|
||||||
|
scm_delv1_x, scm_delete1_x), scmsigs.c (scm_sigaction): Use
|
||||||
|
SCM_FALSEP and SCM_TRUE_P to compare SCM values against #f and
|
||||||
|
#t.
|
||||||
|
|
||||||
|
* list.c (scm_listify): Use SCM_UNBNDP to test for an unbound
|
||||||
|
scheme value.
|
||||||
|
|
||||||
2000-03-29 Mikael Djurfeldt <mdj@thalamus.nada.kth.se>
|
2000-03-29 Mikael Djurfeldt <mdj@thalamus.nada.kth.se>
|
||||||
|
|
||||||
* coop-threads.c (scm_call_with_new_thread, scm_spawn_thread,
|
* coop-threads.c (scm_call_with_new_thread, scm_spawn_thread,
|
||||||
|
|
|
@ -87,7 +87,7 @@ SCM_DEFINE (scm_sloppy_assq, "sloppy-assq", 2, 0, 0,
|
||||||
for (; SCM_CONSP (alist); alist = SCM_CDR (alist))
|
for (; SCM_CONSP (alist); alist = SCM_CDR (alist))
|
||||||
{
|
{
|
||||||
SCM tmp = SCM_CAR (alist);
|
SCM tmp = SCM_CAR (alist);
|
||||||
if (SCM_CONSP (tmp) && SCM_CAR (tmp) == key)
|
if (SCM_CONSP (tmp) && SCM_EQ_P (SCM_CAR (tmp), key))
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
|
@ -151,7 +151,7 @@ SCM_DEFINE (scm_assq, "assq", 2, 0, 0,
|
||||||
{
|
{
|
||||||
SCM tmp = SCM_CAR (alist);
|
SCM tmp = SCM_CAR (alist);
|
||||||
SCM_VALIDATE_CONS (SCM_ARG2, tmp);
|
SCM_VALIDATE_CONS (SCM_ARG2, tmp);
|
||||||
if (SCM_CAR (tmp) == key)
|
if (SCM_EQ_P (SCM_CAR (tmp), key))
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
SCM_VALIDATE_NULL (2, alist);
|
SCM_VALIDATE_NULL (2, alist);
|
||||||
|
|
|
@ -67,7 +67,7 @@ SCM_DEFINE (scm_boolean_p, "boolean?", 1, 0, 0,
|
||||||
"Return #t iff OBJ is either #t or #f.\n")
|
"Return #t iff OBJ is either #t or #f.\n")
|
||||||
#define FUNC_NAME s_scm_boolean_p
|
#define FUNC_NAME s_scm_boolean_p
|
||||||
{
|
{
|
||||||
return SCM_BOOL(SCM_BOOL_F == obj || SCM_BOOL_T == obj);
|
return SCM_BOOL (SCM_BOOLP (obj));
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ SCM_DEFINE1 (scm_eq_p, "eq?", scm_tc7_rpsubr,
|
||||||
"those detectable by `eqv?'.\n")
|
"those detectable by `eqv?'.\n")
|
||||||
#define FUNC_NAME s_scm_eq_p
|
#define FUNC_NAME s_scm_eq_p
|
||||||
{
|
{
|
||||||
return SCM_BOOL(x==y);
|
return SCM_BOOL (SCM_EQ_P (x, y));
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
@ -79,14 +79,14 @@ SCM_DEFINE1 (scm_eqv_p, "eqv?", scm_tc7_rpsubr,
|
||||||
"immediate integers, characters, and inexact numbers.\n")
|
"immediate integers, characters, and inexact numbers.\n")
|
||||||
#define FUNC_NAME s_scm_eqv_p
|
#define FUNC_NAME s_scm_eqv_p
|
||||||
{
|
{
|
||||||
if (x == y)
|
if (SCM_EQ_P (x, y))
|
||||||
return SCM_BOOL_T;
|
return SCM_BOOL_T;
|
||||||
if (SCM_IMP (x))
|
if (SCM_IMP (x))
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
if (SCM_IMP (y))
|
if (SCM_IMP (y))
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
/* this ensures that types and scm_length are the same. */
|
/* this ensures that types and scm_length are the same. */
|
||||||
if (SCM_CAR (x) != SCM_CAR (y))
|
if (SCM_CELL_TYPE (x) != SCM_CELL_TYPE (y))
|
||||||
{
|
{
|
||||||
/* treat mixes of real and complex types specially */
|
/* treat mixes of real and complex types specially */
|
||||||
if (SCM_SLOPPY_INEXACTP (x))
|
if (SCM_SLOPPY_INEXACTP (x))
|
||||||
|
@ -130,7 +130,7 @@ SCM_DEFINE1 (scm_equal_p, "equal?", scm_tc7_rpsubr,
|
||||||
SCM_CHECK_STACK;
|
SCM_CHECK_STACK;
|
||||||
tailrecurse:
|
tailrecurse:
|
||||||
SCM_TICK;
|
SCM_TICK;
|
||||||
if (x == y)
|
if (SCM_EQ_P (x, y))
|
||||||
return SCM_BOOL_T;
|
return SCM_BOOL_T;
|
||||||
if (SCM_IMP (x))
|
if (SCM_IMP (x))
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
|
@ -147,7 +147,7 @@ SCM_DEFINE1 (scm_equal_p, "equal?", scm_tc7_rpsubr,
|
||||||
if (SCM_TYP7S (x) == scm_tc7_string && SCM_TYP7S (y) == scm_tc7_string)
|
if (SCM_TYP7S (x) == scm_tc7_string && SCM_TYP7S (y) == scm_tc7_string)
|
||||||
return scm_string_equal_p (x, y);
|
return scm_string_equal_p (x, y);
|
||||||
/* This ensures that types and scm_length are the same. */
|
/* This ensures that types and scm_length are the same. */
|
||||||
if (SCM_CAR (x) != SCM_CAR (y))
|
if (SCM_CELL_TYPE (x) != SCM_CELL_TYPE (y))
|
||||||
{
|
{
|
||||||
/* treat mixes of real and complex types specially */
|
/* treat mixes of real and complex types specially */
|
||||||
if (SCM_SLOPPY_INEXACTP (x))
|
if (SCM_SLOPPY_INEXACTP (x))
|
||||||
|
|
|
@ -224,7 +224,7 @@ gh_doubles2dvect (double *d, int n)
|
||||||
int
|
int
|
||||||
gh_scm2bool (SCM obj)
|
gh_scm2bool (SCM obj)
|
||||||
{
|
{
|
||||||
return ((obj) == SCM_BOOL_F) ? 0 : 1;
|
return (SCM_FALSEP (obj)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
unsigned long
|
unsigned long
|
||||||
gh_scm2ulong (SCM obj)
|
gh_scm2ulong (SCM obj)
|
||||||
|
@ -687,7 +687,7 @@ SCM
|
||||||
gh_module_lookup (SCM vec, char *sname)
|
gh_module_lookup (SCM vec, char *sname)
|
||||||
{
|
{
|
||||||
SCM sym = gh_symbol2scm (sname);
|
SCM sym = gh_symbol2scm (sname);
|
||||||
if ((scm_symbol_bound_p (vec, sym)) == SCM_BOOL_T)
|
if (SCM_TRUE_P (scm_symbol_bound_p (vec, sym)))
|
||||||
return scm_symbol_binding (vec, sym);
|
return scm_symbol_binding (vec, sym);
|
||||||
else
|
else
|
||||||
return SCM_UNDEFINED;
|
return SCM_UNDEFINED;
|
||||||
|
|
|
@ -69,7 +69,7 @@ scm_listify (SCM elt, ...)
|
||||||
SCM *pos = &answer;
|
SCM *pos = &answer;
|
||||||
|
|
||||||
var_start (foo, elt);
|
var_start (foo, elt);
|
||||||
while (elt != SCM_UNDEFINED)
|
while (! SCM_UNBNDP (elt))
|
||||||
{
|
{
|
||||||
*pos = scm_cons (elt, SCM_EOL);
|
*pos = scm_cons (elt, SCM_EOL);
|
||||||
pos = SCM_CDRLOC (*pos);
|
pos = SCM_CDRLOC (*pos);
|
||||||
|
@ -155,7 +155,7 @@ scm_ilength(SCM sx)
|
||||||
/* For every two steps the hare takes, the tortoise takes one. */
|
/* For every two steps the hare takes, the tortoise takes one. */
|
||||||
tortoise = SCM_CDR(tortoise);
|
tortoise = SCM_CDR(tortoise);
|
||||||
}
|
}
|
||||||
while (hare != tortoise);
|
while (! SCM_EQ_P (hare, tortoise));
|
||||||
|
|
||||||
/* If the tortoise ever catches the hare, then the list must contain
|
/* If the tortoise ever catches the hare, then the list must contain
|
||||||
a cycle. */
|
a cycle. */
|
||||||
|
@ -266,7 +266,7 @@ SCM_DEFINE (scm_last_pair, "last-pair", 1, 0, 0,
|
||||||
hare = ahead;
|
hare = ahead;
|
||||||
tortoise = SCM_CDR(tortoise);
|
tortoise = SCM_CDR(tortoise);
|
||||||
}
|
}
|
||||||
while (hare != tortoise);
|
while (! SCM_EQ_P (hare, tortoise));
|
||||||
SCM_MISC_ERROR ("Circular structure in position 1: ~S", SCM_LIST1 (lst));
|
SCM_MISC_ERROR ("Circular structure in position 1: ~S", SCM_LIST1 (lst));
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
@ -294,7 +294,7 @@ SCM_DEFINE (scm_reverse, "reverse", 1, 0, 0,
|
||||||
hare = SCM_CDR (hare);
|
hare = SCM_CDR (hare);
|
||||||
tortoise = SCM_CDR (tortoise);
|
tortoise = SCM_CDR (tortoise);
|
||||||
}
|
}
|
||||||
while (hare != tortoise);
|
while (! SCM_EQ_P (hare, tortoise));
|
||||||
SCM_MISC_ERROR ("Circular structure in position 1: ~S", SCM_LIST1 (lst));
|
SCM_MISC_ERROR ("Circular structure in position 1: ~S", SCM_LIST1 (lst));
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
@ -479,7 +479,7 @@ SCM_DEFINE (scm_sloppy_memq, "sloppy-memq", 2, 0, 0,
|
||||||
{
|
{
|
||||||
for(; SCM_CONSP (lst); lst = SCM_CDR(lst))
|
for(; SCM_CONSP (lst); lst = SCM_CDR(lst))
|
||||||
{
|
{
|
||||||
if (SCM_CAR(lst)==x)
|
if (SCM_EQ_P (SCM_CAR (lst), x))
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
return lst;
|
return lst;
|
||||||
|
@ -496,7 +496,7 @@ SCM_DEFINE (scm_sloppy_memv, "sloppy-memv", 2, 0, 0,
|
||||||
{
|
{
|
||||||
for(; SCM_CONSP (lst); lst = SCM_CDR(lst))
|
for(; SCM_CONSP (lst); lst = SCM_CDR(lst))
|
||||||
{
|
{
|
||||||
if (SCM_BOOL_F != scm_eqv_p (SCM_CAR(lst), x))
|
if (! SCM_FALSEP (scm_eqv_p (SCM_CAR (lst), x)))
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
return lst;
|
return lst;
|
||||||
|
@ -513,7 +513,7 @@ SCM_DEFINE (scm_sloppy_member, "sloppy-member", 2, 0, 0,
|
||||||
{
|
{
|
||||||
for(; SCM_CONSP (lst); lst = SCM_CDR(lst))
|
for(; SCM_CONSP (lst); lst = SCM_CDR(lst))
|
||||||
{
|
{
|
||||||
if (SCM_BOOL_F != scm_equal_p (SCM_CAR(lst), x))
|
if (! SCM_FALSEP (scm_equal_p (SCM_CAR (lst), x)))
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
return lst;
|
return lst;
|
||||||
|
@ -534,7 +534,7 @@ SCM_DEFINE (scm_memq, "memq", 2, 0, 0,
|
||||||
SCM answer;
|
SCM answer;
|
||||||
SCM_VALIDATE_LIST (2,lst);
|
SCM_VALIDATE_LIST (2,lst);
|
||||||
answer = scm_sloppy_memq (x, lst);
|
answer = scm_sloppy_memq (x, lst);
|
||||||
return (answer == SCM_EOL) ? SCM_BOOL_F : answer;
|
return (SCM_NULLP (answer)) ? SCM_BOOL_F : answer;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ SCM_DEFINE (scm_memv, "memv", 2, 0, 0,
|
||||||
SCM answer;
|
SCM answer;
|
||||||
SCM_VALIDATE_LIST (2,lst);
|
SCM_VALIDATE_LIST (2,lst);
|
||||||
answer = scm_sloppy_memv (x, lst);
|
answer = scm_sloppy_memv (x, lst);
|
||||||
return (answer == SCM_EOL) ? SCM_BOOL_F : answer;
|
return (SCM_NULLP (answer)) ? SCM_BOOL_F : answer;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
@ -569,7 +569,7 @@ SCM_DEFINE (scm_member, "member", 2, 0, 0,
|
||||||
SCM answer;
|
SCM answer;
|
||||||
SCM_VALIDATE_LIST (2,lst);
|
SCM_VALIDATE_LIST (2,lst);
|
||||||
answer = scm_sloppy_member (x, lst);
|
answer = scm_sloppy_member (x, lst);
|
||||||
return (answer == SCM_EOL) ? SCM_BOOL_F : answer;
|
return (SCM_NULLP (answer)) ? SCM_BOOL_F : answer;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ SCM_DEFINE (scm_delq_x, "delq!", 2, 0, 0,
|
||||||
SCM_CONSP (walk);
|
SCM_CONSP (walk);
|
||||||
walk = SCM_CDR (walk))
|
walk = SCM_CDR (walk))
|
||||||
{
|
{
|
||||||
if (SCM_CAR (walk) == item)
|
if (SCM_EQ_P (SCM_CAR (walk), item))
|
||||||
*prev = SCM_CDR (walk);
|
*prev = SCM_CDR (walk);
|
||||||
else
|
else
|
||||||
prev = SCM_CDRLOC (walk);
|
prev = SCM_CDRLOC (walk);
|
||||||
|
@ -619,7 +619,7 @@ SCM_DEFINE (scm_delv_x, "delv!", 2, 0, 0,
|
||||||
SCM_CONSP (walk);
|
SCM_CONSP (walk);
|
||||||
walk = SCM_CDR (walk))
|
walk = SCM_CDR (walk))
|
||||||
{
|
{
|
||||||
if (SCM_BOOL_F != scm_eqv_p (SCM_CAR (walk), item))
|
if (! SCM_FALSEP (scm_eqv_p (SCM_CAR (walk), item)))
|
||||||
*prev = SCM_CDR (walk);
|
*prev = SCM_CDR (walk);
|
||||||
else
|
else
|
||||||
prev = SCM_CDRLOC (walk);
|
prev = SCM_CDRLOC (walk);
|
||||||
|
@ -643,7 +643,7 @@ SCM_DEFINE (scm_delete_x, "delete!", 2, 0, 0,
|
||||||
SCM_CONSP (walk);
|
SCM_CONSP (walk);
|
||||||
walk = SCM_CDR (walk))
|
walk = SCM_CDR (walk))
|
||||||
{
|
{
|
||||||
if (SCM_BOOL_F != scm_equal_p (SCM_CAR (walk), item))
|
if (! SCM_FALSEP (scm_equal_p (SCM_CAR (walk), item)))
|
||||||
*prev = SCM_CDR (walk);
|
*prev = SCM_CDR (walk);
|
||||||
else
|
else
|
||||||
prev = SCM_CDRLOC (walk);
|
prev = SCM_CDRLOC (walk);
|
||||||
|
@ -710,7 +710,7 @@ SCM_DEFINE (scm_delq1_x, "delq1!", 2, 0, 0,
|
||||||
SCM_CONSP (walk);
|
SCM_CONSP (walk);
|
||||||
walk = SCM_CDR (walk))
|
walk = SCM_CDR (walk))
|
||||||
{
|
{
|
||||||
if (SCM_CAR (walk) == item)
|
if (SCM_EQ_P (SCM_CAR (walk), item))
|
||||||
{
|
{
|
||||||
*prev = SCM_CDR (walk);
|
*prev = SCM_CDR (walk);
|
||||||
break;
|
break;
|
||||||
|
@ -737,7 +737,7 @@ SCM_DEFINE (scm_delv1_x, "delv1!", 2, 0, 0,
|
||||||
SCM_CONSP (walk);
|
SCM_CONSP (walk);
|
||||||
walk = SCM_CDR (walk))
|
walk = SCM_CDR (walk))
|
||||||
{
|
{
|
||||||
if (SCM_BOOL_F != scm_eqv_p (SCM_CAR (walk), item))
|
if (! SCM_FALSEP (scm_eqv_p (SCM_CAR (walk), item)))
|
||||||
{
|
{
|
||||||
*prev = SCM_CDR (walk);
|
*prev = SCM_CDR (walk);
|
||||||
break;
|
break;
|
||||||
|
@ -764,7 +764,7 @@ SCM_DEFINE (scm_delete1_x, "delete1!", 2, 0, 0,
|
||||||
SCM_CONSP (walk);
|
SCM_CONSP (walk);
|
||||||
walk = SCM_CDR (walk))
|
walk = SCM_CDR (walk))
|
||||||
{
|
{
|
||||||
if (SCM_BOOL_F != scm_equal_p (SCM_CAR (walk), item))
|
if (! SCM_FALSEP (scm_equal_p (SCM_CAR (walk), item)))
|
||||||
{
|
{
|
||||||
*prev = SCM_CDR (walk);
|
*prev = SCM_CDR (walk);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -240,7 +240,7 @@ SCM_DEFINE (scm_sigaction, "sigaction", 1, 2, 0,
|
||||||
old_handler = scheme_handlers[csig];
|
old_handler = scheme_handlers[csig];
|
||||||
if (SCM_UNBNDP (handler))
|
if (SCM_UNBNDP (handler))
|
||||||
query_only = 1;
|
query_only = 1;
|
||||||
else if (scm_integer_p (handler) == SCM_BOOL_T)
|
else if (SCM_TRUE_P (scm_integer_p (handler)))
|
||||||
{
|
{
|
||||||
if (SCM_NUM2LONG (2,handler) == (long) SIG_DFL
|
if (SCM_NUM2LONG (2,handler) == (long) SIG_DFL
|
||||||
|| SCM_NUM2LONG (2,handler) == (long) SIG_IGN)
|
|| SCM_NUM2LONG (2,handler) == (long) SIG_IGN)
|
||||||
|
|
|
@ -545,7 +545,7 @@ extern char *scm_isymnames[]; /* defined in print.c */
|
||||||
*/
|
*/
|
||||||
#define SCM_UNBOUND SCM_MAKIFLAG (33)
|
#define SCM_UNBOUND SCM_MAKIFLAG (33)
|
||||||
|
|
||||||
#define SCM_UNBNDP(x) (SCM_UNDEFINED == (x))
|
#define SCM_UNBNDP(x) (SCM_EQ_P ((x), SCM_UNDEFINED))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue