diff options
author | Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> | 2000-03-29 16:22:57 +0000 |
---|---|---|
committer | Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> | 2000-03-29 16:22:57 +0000 |
commit | fbd485ba49663beaf82cf4564d4e9b5d900c4c26 (patch) | |
tree | 17771ea08d67edec3bbfaf15e5fd51277bfbdb67 | |
parent | 91163914cfda5c3e911365b3142d981f01eb0f9a (diff) | |
download | guile-fbd485ba49663beaf82cf4564d4e9b5d900c4c26.tar.gz |
Don't use C operators == and != to compare SCM values.
-rw-r--r-- | libguile/ChangeLog | 24 | ||||
-rw-r--r-- | libguile/alist.c | 4 | ||||
-rw-r--r-- | libguile/boolean.c | 2 | ||||
-rw-r--r-- | libguile/eq.c | 10 | ||||
-rw-r--r-- | libguile/gh_data.c | 4 | ||||
-rw-r--r-- | libguile/list.c | 32 | ||||
-rw-r--r-- | libguile/scmsigs.c | 2 | ||||
-rw-r--r-- | libguile/tags.h | 2 |
8 files changed, 52 insertions, 28 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog index f2a3eaab7..fa5b6b56c 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -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> * coop-threads.c (scm_call_with_new_thread, scm_spawn_thread, diff --git a/libguile/alist.c b/libguile/alist.c index 4e11781cd..31936db85 100644 --- a/libguile/alist.c +++ b/libguile/alist.c @@ -87,7 +87,7 @@ SCM_DEFINE (scm_sloppy_assq, "sloppy-assq", 2, 0, 0, for (; SCM_CONSP (alist); alist = SCM_CDR (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 SCM_BOOL_F; @@ -151,7 +151,7 @@ SCM_DEFINE (scm_assq, "assq", 2, 0, 0, { SCM tmp = SCM_CAR (alist); SCM_VALIDATE_CONS (SCM_ARG2, tmp); - if (SCM_CAR (tmp) == key) + if (SCM_EQ_P (SCM_CAR (tmp), key)) return tmp; } SCM_VALIDATE_NULL (2, alist); diff --git a/libguile/boolean.c b/libguile/boolean.c index a2353459e..39774dfaf 100644 --- a/libguile/boolean.c +++ b/libguile/boolean.c @@ -67,7 +67,7 @@ SCM_DEFINE (scm_boolean_p, "boolean?", 1, 0, 0, "Return #t iff OBJ is either #t or #f.\n") #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 diff --git a/libguile/eq.c b/libguile/eq.c index 73e5f1fa8..0d054e931 100644 --- a/libguile/eq.c +++ b/libguile/eq.c @@ -65,7 +65,7 @@ SCM_DEFINE1 (scm_eq_p, "eq?", scm_tc7_rpsubr, "those detectable by `eqv?'.\n") #define FUNC_NAME s_scm_eq_p { - return SCM_BOOL(x==y); + return SCM_BOOL (SCM_EQ_P (x, y)); } #undef FUNC_NAME @@ -79,14 +79,14 @@ SCM_DEFINE1 (scm_eqv_p, "eqv?", scm_tc7_rpsubr, "immediate integers, characters, and inexact numbers.\n") #define FUNC_NAME s_scm_eqv_p { - if (x == y) + if (SCM_EQ_P (x, y)) return SCM_BOOL_T; if (SCM_IMP (x)) return SCM_BOOL_F; if (SCM_IMP (y)) return SCM_BOOL_F; /* 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 */ if (SCM_SLOPPY_INEXACTP (x)) @@ -130,7 +130,7 @@ SCM_DEFINE1 (scm_equal_p, "equal?", scm_tc7_rpsubr, SCM_CHECK_STACK; tailrecurse: SCM_TICK; - if (x == y) + if (SCM_EQ_P (x, y)) return SCM_BOOL_T; if (SCM_IMP (x)) 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) return scm_string_equal_p (x, y); /* 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 */ if (SCM_SLOPPY_INEXACTP (x)) diff --git a/libguile/gh_data.c b/libguile/gh_data.c index ab837ef9e..39a56a1b8 100644 --- a/libguile/gh_data.c +++ b/libguile/gh_data.c @@ -224,7 +224,7 @@ gh_doubles2dvect (double *d, int n) int gh_scm2bool (SCM obj) { - return ((obj) == SCM_BOOL_F) ? 0 : 1; + return (SCM_FALSEP (obj)) ? 0 : 1; } unsigned long gh_scm2ulong (SCM obj) @@ -687,7 +687,7 @@ SCM gh_module_lookup (SCM vec, char *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); else return SCM_UNDEFINED; diff --git a/libguile/list.c b/libguile/list.c index c5695991a..28c890532 100644 --- a/libguile/list.c +++ b/libguile/list.c @@ -69,7 +69,7 @@ scm_listify (SCM elt, ...) SCM *pos = &answer; var_start (foo, elt); - while (elt != SCM_UNDEFINED) + while (! SCM_UNBNDP (elt)) { *pos = scm_cons (elt, SCM_EOL); pos = SCM_CDRLOC (*pos); @@ -155,7 +155,7 @@ scm_ilength(SCM sx) /* For every two steps the hare takes, the tortoise takes one. */ 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 a cycle. */ @@ -266,7 +266,7 @@ SCM_DEFINE (scm_last_pair, "last-pair", 1, 0, 0, hare = ahead; 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)); } #undef FUNC_NAME @@ -294,7 +294,7 @@ SCM_DEFINE (scm_reverse, "reverse", 1, 0, 0, hare = SCM_CDR (hare); 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)); } #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)) { - if (SCM_CAR(lst)==x) + if (SCM_EQ_P (SCM_CAR (lst), x)) 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)) { - 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; @@ -513,7 +513,7 @@ SCM_DEFINE (scm_sloppy_member, "sloppy-member", 2, 0, 0, { 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; @@ -534,7 +534,7 @@ SCM_DEFINE (scm_memq, "memq", 2, 0, 0, SCM answer; SCM_VALIDATE_LIST (2,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 @@ -552,7 +552,7 @@ SCM_DEFINE (scm_memv, "memv", 2, 0, 0, SCM answer; SCM_VALIDATE_LIST (2,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 @@ -569,7 +569,7 @@ SCM_DEFINE (scm_member, "member", 2, 0, 0, SCM answer; SCM_VALIDATE_LIST (2,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 @@ -596,7 +596,7 @@ SCM_DEFINE (scm_delq_x, "delq!", 2, 0, 0, SCM_CONSP (walk); walk = SCM_CDR (walk)) { - if (SCM_CAR (walk) == item) + if (SCM_EQ_P (SCM_CAR (walk), item)) *prev = SCM_CDR (walk); else prev = SCM_CDRLOC (walk); @@ -619,7 +619,7 @@ SCM_DEFINE (scm_delv_x, "delv!", 2, 0, 0, SCM_CONSP (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); else prev = SCM_CDRLOC (walk); @@ -643,7 +643,7 @@ SCM_DEFINE (scm_delete_x, "delete!", 2, 0, 0, SCM_CONSP (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); else prev = SCM_CDRLOC (walk); @@ -710,7 +710,7 @@ SCM_DEFINE (scm_delq1_x, "delq1!", 2, 0, 0, SCM_CONSP (walk); walk = SCM_CDR (walk)) { - if (SCM_CAR (walk) == item) + if (SCM_EQ_P (SCM_CAR (walk), item)) { *prev = SCM_CDR (walk); break; @@ -737,7 +737,7 @@ SCM_DEFINE (scm_delv1_x, "delv1!", 2, 0, 0, SCM_CONSP (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); break; @@ -764,7 +764,7 @@ SCM_DEFINE (scm_delete1_x, "delete1!", 2, 0, 0, SCM_CONSP (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); break; diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index 0a767603b..29ab50235 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -240,7 +240,7 @@ SCM_DEFINE (scm_sigaction, "sigaction", 1, 2, 0, old_handler = scheme_handlers[csig]; if (SCM_UNBNDP (handler)) 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 || SCM_NUM2LONG (2,handler) == (long) SIG_IGN) diff --git a/libguile/tags.h b/libguile/tags.h index 3993c9972..3b0fdf6c9 100644 --- a/libguile/tags.h +++ b/libguile/tags.h @@ -545,7 +545,7 @@ extern char *scm_isymnames[]; /* defined in print.c */ */ #define SCM_UNBOUND SCM_MAKIFLAG (33) -#define SCM_UNBNDP(x) (SCM_UNDEFINED == (x)) +#define SCM_UNBNDP(x) (SCM_EQ_P ((x), SCM_UNDEFINED)) |