summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorGreg J. Badros <gjb@cs.washington.edu>1999-12-16 03:46:42 +0000
committerGreg J. Badros <gjb@cs.washington.edu>1999-12-16 03:46:42 +0000
commitd3a6bc94840464e1af8109de5dddd5859560c679 (patch)
tree87475ee6d125df4493b89e5e6a9a13933c8ab356 /libguile
parentf353a9e2323b3957cd8475bcf10f7b489a8ce000 (diff)
downloadguile-d3a6bc94840464e1af8109de5dddd5859560c679.tar.gz
* *.h: Use SCM_NIMP(X) && in all the FOOP macros.
* *.[ch]: Use do { ... } while (0) idiom in macros that expanded to a bare block.
Diffstat (limited to 'libguile')
-rw-r--r--libguile/async.h5
-rw-r--r--libguile/coop-defs.h11
-rw-r--r--libguile/debug.h11
-rw-r--r--libguile/dynwind.c2
-rw-r--r--libguile/eval.c4
-rw-r--r--libguile/feature.h5
-rw-r--r--libguile/filesys.h7
-rw-r--r--libguile/fluids.h5
-rw-r--r--libguile/fports.h11
-rw-r--r--libguile/fsu-pthreads.h19
-rw-r--r--libguile/gc.h5
-rw-r--r--libguile/gdbint.c12
-rw-r--r--libguile/guardians.c8
-rw-r--r--libguile/keywords.h5
-rw-r--r--libguile/mit-pthreads.h27
-rw-r--r--libguile/numbers.h17
-rw-r--r--libguile/ports.h17
-rw-r--r--libguile/print.h9
-rw-r--r--libguile/procs.h7
-rw-r--r--libguile/random.h5
-rw-r--r--libguile/regex-posix.h5
-rw-r--r--libguile/root.h5
-rw-r--r--libguile/srcprop.h9
-rw-r--r--libguile/stacks.c4
-rw-r--r--libguile/stacks.h7
-rw-r--r--libguile/strings.h7
-rw-r--r--libguile/struct.h5
-rw-r--r--libguile/symbols.h19
-rw-r--r--libguile/tags.h4
-rw-r--r--libguile/threads.h9
-rw-r--r--libguile/throw.c2
-rw-r--r--libguile/unif.h5
-rw-r--r--libguile/variable.h5
-rw-r--r--libguile/vectors.h5
-rw-r--r--libguile/weaks.h5
35 files changed, 186 insertions, 102 deletions
diff --git a/libguile/async.h b/libguile/async.h
index 5c7053ba7..d44023165 100644
--- a/libguile/async.h
+++ b/libguile/async.h
@@ -42,13 +42,16 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
-#define SCM_ASYNCP(X) (scm_tc16_async == SCM_GCTYP16 (X))
+#define SCM_ASYNCP(X) (SCM_NIMP(X) && (scm_tc16_async == SCM_GCTYP16 (X)))
#define SCM_ASYNC(X) ((struct scm_async *)SCM_CDR (X))
struct scm_async
diff --git a/libguile/coop-defs.h b/libguile/coop-defs.h
index 3764ff856..39a9e192b 100644
--- a/libguile/coop-defs.h
+++ b/libguile/coop-defs.h
@@ -43,6 +43,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
# ifdef TIME_WITH_SYS_TIME
@@ -201,14 +204,14 @@ extern coop_t *coop_wait_for_runnable_thread (void);
#if 0
#define SCM_THREAD_SWITCHING_CODE \
-{ \
+do { \
if (scm_thread_count > 1) \
coop_yield(); \
-} \
+} while (0)
#else
#define SCM_THREAD_SWITCHING_CODE \
-{ \
+do { \
if (scm_thread_count > 1) \
{ \
scm_switch_counter--; \
@@ -218,7 +221,7 @@ extern coop_t *coop_wait_for_runnable_thread (void);
coop_yield(); \
} \
} \
-} \
+} while (0)
#endif
diff --git a/libguile/debug.h b/libguile/debug.h
index 87161488a..a3e69bfd1 100644
--- a/libguile/debug.h
+++ b/libguile/debug.h
@@ -45,6 +45,9 @@
*
* The author can be reached at djurfeldt@nada.kth.se
* Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -93,13 +96,13 @@ extern int scm_check_entry_p, scm_check_apply_p, scm_check_exit_p;
#define CHECK_EXIT scm_check_exit_p
#define SCM_RESET_DEBUG_MODE \
-{\
+do {\
CHECK_ENTRY = SCM_ENTER_FRAME_P || SCM_BREAKPOINTS_P;\
CHECK_APPLY = SCM_APPLY_FRAME_P || SCM_TRACE_P;\
CHECK_EXIT = SCM_EXIT_FRAME_P || SCM_TRACE_P;\
scm_debug_mode = SCM_DEVAL_P || CHECK_ENTRY || CHECK_APPLY || CHECK_EXIT;\
scm_ceval_ptr = scm_debug_mode ? scm_deval : scm_ceval;\
-}
+} while (0)
/* {Evaluator}
@@ -163,7 +166,7 @@ extern scm_debug_frame *scm_last_debug_frame;
extern long scm_tc16_debugobj;
-#define SCM_DEBUGOBJP(x) (scm_tc16_debugobj == SCM_TYP16 (x))
+#define SCM_DEBUGOBJP(x) (SCM_NIMP(x) && (scm_tc16_debugobj == SCM_TYP16 (x)))
#define SCM_DEBUGOBJ_FRAME(x) SCM_CDR (x)
#define SCM_SET_DEBUGOBJ_FRAME(x, f) SCM_SETCDR (x, f)
@@ -172,7 +175,7 @@ extern long scm_tc16_debugobj;
extern long scm_tc16_memoized;
-#define SCM_MEMOIZEDP(x) (scm_tc16_memoized == SCM_TYP16 (x))
+#define SCM_MEMOIZEDP(x) (SCM_NIMP(x) && (scm_tc16_memoized == SCM_TYP16 (x)))
#define SCM_MEMOIZED_EXP(x) SCM_CAR (SCM_CDR (x))
#define SCM_MEMOIZED_ENV(x) SCM_CDR (SCM_CDR (x))
diff --git a/libguile/dynwind.c b/libguile/dynwind.c
index 8b6fedd70..be2084af7 100644
--- a/libguile/dynwind.c
+++ b/libguile/dynwind.c
@@ -156,7 +156,7 @@ typedef struct guardsmem {
#define SCM_BEFORE_GUARD(obj) (SCM_GUARDSMEM (obj)->before)
#define SCM_AFTER_GUARD(obj) (SCM_GUARDSMEM (obj)->after)
#define SCM_GUARD_DATA(obj) (SCM_GUARDSMEM (obj)->data)
-#define SCM_GUARDSP(obj) (SCM_CAR (obj) == tc16_guards)
+#define SCM_GUARDSP(obj) (SCM_NIMP(obj) && (SCM_CAR (obj) == tc16_guards))
static long tc16_guards;
diff --git a/libguile/eval.c b/libguile/eval.c
index 9282b2bfe..563936718 100644
--- a/libguile/eval.c
+++ b/libguile/eval.c
@@ -1611,7 +1611,7 @@ scm_eval_body (SCM code, SCM env)
{ ++debug.info; debug.info->a.proc = p; debug.info->a.args = l; }
#undef ENTER_APPLY
#define ENTER_APPLY \
-{\
+do { \
SCM_SET_ARGSREADY (debug);\
if (CHECK_APPLY && SCM_TRAPS_P)\
if (SCM_APPLY_FRAME_P || (SCM_TRACE_P && PROCTRACEP (proc)))\
@@ -1630,7 +1630,7 @@ scm_eval_body (SCM code, SCM env)
scm_ithrow (scm_sym_apply_frame, scm_cons2 (tmp, tail, SCM_EOL), 0);\
}\
}\
-}
+} while (0)
#undef RETURN
#define RETURN(e) {proc = (e); goto exit;}
#ifdef STACK_CHECKING
diff --git a/libguile/feature.h b/libguile/feature.h
index aa61c740f..8ba59891b 100644
--- a/libguile/feature.h
+++ b/libguile/feature.h
@@ -42,11 +42,14 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
-#define SCM_HOOKP(x) (SCM_TYP16 (x) == scm_tc16_hook)
+#define SCM_HOOKP(x) (SCM_NIMP(x) && (SCM_TYP16 (x) == scm_tc16_hook))
#define SCM_HOOK_ARITY(hook) (SCM_CAR (hook) >> 16)
#define SCM_HOOK_NAME(hook) SCM_CADR (hook)
#define SCM_HOOK_PROCEDURES(hook) SCM_CDDR (hook)
diff --git a/libguile/filesys.h b/libguile/filesys.h
index 294cc2368..c503f4fea 100644
--- a/libguile/filesys.h
+++ b/libguile/filesys.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include <stdio.h>
@@ -50,8 +53,8 @@
extern long scm_tc16_dir;
-#define SCM_DIRP(x) (SCM_TYP16(x)==(scm_tc16_dir))
-#define SCM_OPDIRP(x) (SCM_CAR(x)==(scm_tc16_dir | SCM_OPN))
+#define SCM_DIRP(x) (SCM_NIMP(x) && (SCM_TYP16(x)==(scm_tc16_dir)))
+#define SCM_OPDIRP(x) (SCM_NIMP(x) && (SCM_CAR(x)==(scm_tc16_dir | SCM_OPN)))
extern SCM scm_chown SCM_P ((SCM object, SCM owner, SCM group));
diff --git a/libguile/fluids.h b/libguile/fluids.h
index 867528f70..10d7a9431 100644
--- a/libguile/fluids.h
+++ b/libguile/fluids.h
@@ -44,6 +44,9 @@
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
+
#include "libguile/__scm.h"
#include "libguile/root.h"
#include "libguile/vectors.h"
@@ -72,7 +75,7 @@
extern long scm_tc16_fluid;
-#define SCM_FLUIDP(x) (SCM_CAR(x) == scm_tc16_fluid)
+#define SCM_FLUIDP(x) (SCM_NIMP(x) && (SCM_CAR(x) == scm_tc16_fluid))
#define SCM_FLUID_NUM(x) SCM_CDR(x)
/* The fastest way to acces/modify the value of a fluid. These macros
diff --git a/libguile/fports.h b/libguile/fports.h
index 78619c7fd..dcd0f1928 100644
--- a/libguile/fports.h
+++ b/libguile/fports.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -58,10 +61,10 @@ struct scm_fport {
#define SCM_FSTREAM(x) ((struct scm_fport *) SCM_STREAM (x))
#define SCM_FPORT_FDES(x) (SCM_FSTREAM (x)->fdes)
-#define SCM_FPORTP(x) (SCM_TYP16S(x)==scm_tc7_port)
-#define SCM_OPFPORTP(x) (((0xfeff | SCM_OPN) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN))
-#define SCM_OPINFPORTP(x) (((0xfeff | SCM_OPN | SCM_RDNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_RDNG))
-#define SCM_OPOUTFPORTP(x) (((0xfeff | SCM_OPN | SCM_WRTNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_WRTNG))
+#define SCM_FPORTP(x) (SCM_NIMP(x) && (SCM_TYP16S(x)==scm_tc7_port))
+#define SCM_OPFPORTP(x) (SCM_NIMP(x) && (((0xfeff | SCM_OPN) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN)))
+#define SCM_OPINFPORTP(x) (SCM_NIMP(x) && (((0xfeff | SCM_OPN | SCM_RDNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_RDNG)))
+#define SCM_OPOUTFPORTP(x) (SCM_NIMP(x) && (((0xfeff | SCM_OPN | SCM_WRTNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_WRTNG)))
/* test whether fdes supports random access. */
#define SCM_FDES_RANDOM_P(fdes) ((lseek (fdes, 0, SEEK_CUR) == -1) ? 0 : 1)
diff --git a/libguile/fsu-pthreads.h b/libguile/fsu-pthreads.h
index 49ea144b0..a012b1eb2 100644
--- a/libguile/fsu-pthreads.h
+++ b/libguile/fsu-pthreads.h
@@ -38,6 +38,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#ifndef SCM_FSU_PTHREADS_H
@@ -99,24 +102,24 @@
#define SCM_NO_CRITICAL_SECTION_OWNER 0
#define SCM_DEFER_INTS \
-{ \
+do { \
SCM_IASSERT(scm_critical_section_owner != pthread_self()); \
pthread_mutex_lock(&scm_critical_section_mutex); \
scm_critical_section_owner = pthread_self(); \
scm_ints_disabled = 1; \
-}
+} while (0)
#define SCM_ALLOW_INTS \
-{ \
+do { \
SCM_IASSERT(scm_critical_section_owner == pthread_self()); \
scm_ints_disabled = 0; \
scm_critical_section_owner = SCM_NO_CRITICAL_SECTION_OWNER; \
pthread_mutex_unlock(&scm_critical_section_mutex); \
SCM_CHECK_INTS; \
-}
+} while (0)
#define SCM_REDEFER_INTS \
-{ \
+do { \
if ((scm_critical_section_owner != pthread_self()) || \
(scm_critical_section_owner == SCM_NO_CRITICAL_SECTION_OWNER)) \
{ \
@@ -124,10 +127,10 @@
scm_critical_section_owner = pthread_self(); \
} \
++scm_ints_disabled; \
-}
+} while (0)
#define SCM_REALLOW_INTS \
-{ \
+do { \
SCM_IASSERT(scm_critical_section_owner == pthread_self()); \
--scm_ints_disabled; \
if (!scm_ints_disabled) \
@@ -136,7 +139,7 @@
pthread_mutex_unlock(&scm_critical_section_mutex); \
SCM_CHECK_INTS; \
} \
-}
+} while (0)
*fixme*
#define scm_root ((scm_root_state *) pthread_self()->prots)
diff --git a/libguile/gc.h b/libguile/gc.h
index 8d0c825c0..c06526b02 100644
--- a/libguile/gc.h
+++ b/libguile/gc.h
@@ -42,12 +42,15 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
-#define SCM_FREEP(x) (SCM_CAR(x)==scm_tc_free_cell)
+#define SCM_FREEP(x) (SCM_NIMP(x) && SCM_CAR(x)==scm_tc_free_cell)
#define SCM_NFREEP(x) (!SCM_FREEP(x))
/* 1. This shouldn't be used on immediates.
diff --git a/libguile/gdbint.c b/libguile/gdbint.c
index c219dbd32..6e0b294b3 100644
--- a/libguile/gdbint.c
+++ b/libguile/gdbint.c
@@ -87,28 +87,28 @@
* debugger.
*/
#define SCM_BEGIN_FOREIGN_BLOCK \
-{ \
+do { \
old_ints = scm_ints_disabled; scm_ints_disabled = 1; \
old_gc = scm_block_gc; scm_block_gc = 1; \
scm_print_carefully_p = 1; \
-} \
+} while (0)
#define SCM_END_FOREIGN_BLOCK \
-{ \
+do { \
scm_print_carefully_p = 0; \
scm_block_gc = old_gc; \
scm_ints_disabled = old_ints; \
-} \
+} while (0)
#define RESET_STRING { gdb_output_length = 0; }
#define SEND_STRING(str) \
-{ \
+do { \
gdb_output = str; \
gdb_output_length = strlen (str); \
-} \
+} while (0)
/* {Gdb interface}
diff --git a/libguile/guardians.c b/libguile/guardians.c
index 32a5db184..66e1e00ff 100644
--- a/libguile/guardians.c
+++ b/libguile/guardians.c
@@ -72,19 +72,19 @@ static long scm_tc16_guardian;
so that no synchronization between these needs to take place.
*/
#define TCONC_IN(tc, obj, pair) \
-{ \
+do { \
SCM_SETCAR ((tc).tail, obj); \
SCM_SETCAR (pair, SCM_BOOL_F); \
SCM_SETCDR (pair, SCM_BOOL_F); \
SCM_SETCDR ((tc).tail, pair); \
(tc).tail = pair; \
-} \
+} while (0)
#define TCONC_OUT(tc, res) \
-{ \
+do { \
(res) = SCM_CAR ((tc).head); \
(tc).head = SCM_CDR ((tc).head); \
-} \
+} while (0)
#define TCONC_EMPTYP(tc) ((tc).head == (tc).tail)
diff --git a/libguile/keywords.h b/libguile/keywords.h
index 6c122b83e..3bac1bbf9 100644
--- a/libguile/keywords.h
+++ b/libguile/keywords.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -49,7 +52,7 @@
extern int scm_tc16_keyword;
-#define SCM_KEYWORDP(X) (SCM_CAR(X) == scm_tc16_keyword)
+#define SCM_KEYWORDP(X) (SCM_NIMP(X) && (SCM_CAR(X) == scm_tc16_keyword))
#define SCM_KEYWORDSYM(X) (SCM_CDR(X))
diff --git a/libguile/mit-pthreads.h b/libguile/mit-pthreads.h
index 316eff217..ecd21cdd9 100644
--- a/libguile/mit-pthreads.h
+++ b/libguile/mit-pthreads.h
@@ -43,6 +43,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -111,43 +114,43 @@
#define SCM_THREAD_REDEFER pthread_kernel_lock++
#define SCM_THREAD_REALLOW_1 pthread_kernel_lock--
#define SCM_THREAD_REALLOW_2 \
-{ \
+do { \
scm_critical_section_owner = SCM_NO_CRITICAL_SECTION_OWNER; \
pthread_mutex_unlock(&scm_critical_section_mutex); \
-}
+} while (0)
#else
#define SCM_NO_CRITICAL_SECTION_OWNER 0
#define SCM_THREAD_DEFER \
-{ \
+do { \
pthread_mutex_lock (&scm_critical_section_mutex); \
scm_critical_section_owner = pthread_self(); \
-}
+} while (0)
#define SCM_THREAD_ALLOW \
-{ \
+do { \
scm_critical_section_owner = SCM_NO_CRITICAL_SECTION_OWNER; \
pthread_mutex_unlock (&scm_critical_section_mutex); \
-}
+} while (0)
#define SCM_THREAD_REDEFER \
-{ \
+do { \
if ((scm_critical_section_owner != pthread_self()) || \
(scm_critical_section_owner == SCM_NO_CRITICAL_SECTION_OWNER)) \
{ \
pthread_mutex_lock(&scm_critical_section_mutex); \
scm_critical_section_owner = pthread_self(); \
} \
-}
+} while (0)
#define SCM_THREAD_REALLOW_1
#define SCM_THREAD_REALLOW_2 \
-{ \
+do { \
scm_critical_section_owner = SCM_NO_CRITICAL_SECTION_OWNER; \
pthread_mutex_unlock (&scm_critical_section_mutex); \
-}
+} while (0)
#endif
@@ -155,12 +158,12 @@
#define SCM_THREAD_LOCAL_DATA (pthread_self () -> attr.arg_attr)
#define SCM_SET_THREAD_LOCAL_DATA(new_root) \
-{ \
+do { \
pthread_t t = pthread_self (); \
void *r = (new_root); \
pthread_attr_setcleanup (&t -> attr, NULL, r); \
pthreads_find_info (t) -> root = r; \
-}
+} while (0)
diff --git a/libguile/numbers.h b/libguile/numbers.h
index d62de4c67..f09c1cba5 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -128,20 +131,20 @@
/* Numbers
*/
-#define SCM_INEXP(x) (SCM_TYP16(x)==scm_tc16_flo)
-#define SCM_CPLXP(x) (SCM_CAR(x)==scm_tc_dblc)
+#define SCM_INEXP(x) (SCM_NIMP(x) && (SCM_TYP16(x)==scm_tc16_flo))
+#define SCM_CPLXP(x) (SCM_NIMP(x) && (SCM_CAR(x)==scm_tc_dblc))
#define SCM_REAL(x) (*(((scm_dbl *) (SCM2PTR(x)))->real))
#define SCM_IMAG(x) (*((double *)(SCM_CHARS(x)+sizeof(double))))
/* ((&SCM_REAL(x))[1]) */
#ifdef SCM_SINGLES
-#define SCM_REALP(x) ((~SCM_REAL_PART & SCM_CAR(x))==scm_tc_flo)
-#define SCM_SINGP(x) (SCM_CAR(x)==scm_tc_flo)
+#define SCM_REALP(x) (SCM_NIMP(x) && ((~SCM_REAL_PART & SCM_CAR(x))==scm_tc_flo))
+#define SCM_SINGP(x) (SCM_NIMP(x) && (SCM_CAR(x)==scm_tc_flo))
#define SCM_FLO(x) (((scm_flo *)(SCM2PTR(x)))->num)
#define SCM_REALPART(x) (SCM_SINGP(x)?0.0+SCM_FLO(x):SCM_REAL(x))
#else /* SCM_SINGLES */
-#define SCM_REALP(x) (SCM_CAR(x)==scm_tc_dblr)
+#define SCM_REALP(x) (SCM_NIMP(x) && (SCM_CAR(x)==scm_tc_dblr))
#define SCM_REALPART SCM_REAL
#endif /* SCM_SINGLES */
@@ -209,8 +212,8 @@
#define SCM_NUM2DBL(x) ((double) SCM_INUM (x))
#endif
#endif
-#define SCM_NUMP(x) ((0xfcff & (int)SCM_CAR(x))==scm_tc7_smob)
-#define SCM_BIGP(x) (SCM_TYP16S(x)==scm_tc16_bigpos)
+#define SCM_NUMP(x) (SCM_NIMP(x) && (0xfcff & (int)SCM_CAR(x))==scm_tc7_smob)
+#define SCM_BIGP(x) (SCM_NIMP(x) && SCM_TYP16S(x)==scm_tc16_bigpos)
#define SCM_BIGSIGN(x) (0x0100 & (int)SCM_CAR(x))
#define SCM_BDIGITS(x) ((SCM_BIGDIG *)(SCM_CDR(x)))
#define SCM_NUMDIGS(x) ((scm_sizet)(SCM_CAR(x)>>16))
diff --git a/libguile/ports.h b/libguile/ports.h
index 593406879..92781315c 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -150,13 +153,13 @@ extern int scm_port_table_size; /* Number of ports in scm_port_table. */
/* #define SCM_CRDY (32L<<16) obsolete, for pushed back characters */
#define SCM_BUFLINE (64L<<16) /* Is it line-buffered? */
-#define SCM_PORTP(x) (SCM_TYP7(x)==scm_tc7_port)
-#define SCM_OPPORTP(x) (((0x7f | SCM_OPN) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN))
-#define SCM_OPINPORTP(x) (((0x7f | SCM_OPN | SCM_RDNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_RDNG))
-#define SCM_OPOUTPORTP(x) (((0x7f | SCM_OPN | SCM_WRTNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_WRTNG))
-#define SCM_INPORTP(x) (((0x7f | SCM_RDNG) & SCM_CAR(x))==(scm_tc7_port | SCM_RDNG))
-#define SCM_OUTPORTP(x) (((0x7f | SCM_WRTNG) & SCM_CAR(x))==(scm_tc7_port | SCM_WRTNG))
-#define SCM_OPENP(x) (SCM_OPN & SCM_CAR(x))
+#define SCM_PORTP(x) (SCM_NIMP(x) && (SCM_TYP7(x)==scm_tc7_port))
+#define SCM_OPPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN)))
+#define SCM_OPINPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN | SCM_RDNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_RDNG)))
+#define SCM_OPOUTPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN | SCM_WRTNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_WRTNG)))
+#define SCM_INPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_RDNG) & SCM_CAR(x))==(scm_tc7_port | SCM_RDNG)))
+#define SCM_OUTPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_WRTNG) & SCM_CAR(x))==(scm_tc7_port | SCM_WRTNG)))
+#define SCM_OPENP(x) (SCM_NIMP(x) && (SCM_OPN & SCM_CAR(x)))
#define SCM_CLOSEDP(x) (!SCM_OPENP(x))
#define SCM_PTAB_ENTRY(x) ((scm_port *) SCM_CDR(x))
#define SCM_SETPTAB_ENTRY(x,ent) SCM_SETCDR ((x), (SCM)(ent))
diff --git a/libguile/print.h b/libguile/print.h
index 2701153be..38ba1ac75 100644
--- a/libguile/print.h
+++ b/libguile/print.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -62,15 +65,15 @@ extern scm_option scm_print_opts[];
#define SCM_PRINT_STATE(obj) ((scm_print_state *) SCM_STRUCT_DATA (obj))
#define RESET_PRINT_STATE(pstate) \
-{ \
+do { \
pstate->list_offset = 0; \
pstate->top = 0; \
-}
+} while (0)
#define SCM_WRITINGP(pstate) ((pstate)->writingp)
#define SCM_SET_WRITINGP(pstate, x) { (pstate)->writingp = (x); }
-#define SCM_PORT_WITH_PS_P(p) (SCM_TYP16 (p) == scm_tc16_port_with_ps)
+#define SCM_PORT_WITH_PS_P(p) (SCM_NIMP(p) && (SCM_TYP16 (p) == scm_tc16_port_with_ps))
#define SCM_PORT_WITH_PS_PORT(p) SCM_CADR (p)
#define SCM_PORT_WITH_PS_PS(p) SCM_CDDR (p)
diff --git a/libguile/procs.h b/libguile/procs.h
index 11cfb1f0d..c62e78497 100644
--- a/libguile/procs.h
+++ b/libguile/procs.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -97,7 +100,7 @@ typedef struct
/* Closures
*/
-#define SCM_CLOSUREP(x) (SCM_TYP3(x)==scm_tc3_closure)
+#define SCM_CLOSUREP(x) (SCM_NIMP(x) && (SCM_TYP3(x)==scm_tc3_closure))
#define SCM_CLOSCAR(x) (SCM_CAR(x)-scm_tc3_closure)
#define SCM_CODE(x) SCM_CAR(SCM_CLOSCAR (x))
#define SCM_PROCPROPS(x) SCM_CDR(SCM_CLOSCAR (x))
@@ -154,7 +157,7 @@ typedef struct
GETTER and SETTER slots can live directly on the heap, using the
new four-word cells. */
-#define SCM_PROCEDURE_WITH_SETTER_P(obj) (SCM_TYP7 (obj) == scm_tc7_pws)
+#define SCM_PROCEDURE_WITH_SETTER_P(obj) (SCM_NIMP(obj) && (SCM_TYP7 (obj) == scm_tc7_pws))
#define SCM_PROCEDURE(obj) SCM_CADR (obj)
#define SCM_SETTER(obj) SCM_CDDR (obj)
diff --git a/libguile/random.h b/libguile/random.h
index b933e5f71..04651dcfe 100644
--- a/libguile/random.h
+++ b/libguile/random.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -107,7 +110,7 @@ extern SCM scm_c_random_bignum (scm_rstate *, SCM m);
*/
extern long scm_tc16_rstate;
#define SCM_RSTATE(obj) ((scm_rstate *) SCM_CDR (obj))
-#define SCM_RSTATEP(obj) (SCM_TYP16 (obj) == scm_tc16_rstate)
+#define SCM_RSTATEP(obj) (SCM_NIMP(obj) && (SCM_TYP16 (obj) == scm_tc16_rstate))
extern unsigned char scm_masktab[256];
diff --git a/libguile/regex-posix.h b/libguile/regex-posix.h
index 3290ffcf5..172ed928c 100644
--- a/libguile/regex-posix.h
+++ b/libguile/regex-posix.h
@@ -45,11 +45,14 @@
* If you do not wish that, delete this exception notice.
*/
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
+
#include "libguile/__scm.h"
extern long scm_tc16_regex;
#define SCM_RGX(X) ((regex_t *) SCM_CDR(X))
-#define SCM_RGXP(X) (SCM_CAR (X) == (SCM) scm_tc16_regex)
+#define SCM_RGXP(X) (SCM_NIMP(X) && (SCM_CAR (X) == (SCM) scm_tc16_regex))
extern SCM scm_make_regexp SCM_P ((SCM pat, SCM flags));
SCM scm_regexp_p SCM_P ((SCM x));
diff --git a/libguile/root.h b/libguile/root.h
index cb6cc080b..12e2bbec1 100644
--- a/libguile/root.h
+++ b/libguile/root.h
@@ -43,6 +43,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
@@ -82,7 +85,7 @@ extern SCM scm_sys_protects[];
extern long scm_tc16_root;
-#define SCM_ROOTP(obj) (scm_tc16_root == SCM_TYP16 (obj))
+#define SCM_ROOTP(obj) (SCM_NIMP(obj) && (scm_tc16_root == SCM_TYP16 (obj)))
#define SCM_ROOT_STATE(root) ((scm_root_state *) SCM_CDR (root))
typedef struct scm_root_state
diff --git a/libguile/srcprop.h b/libguile/srcprop.h
index 8b44381ca..e6820d6c8 100644
--- a/libguile/srcprop.h
+++ b/libguile/srcprop.h
@@ -45,6 +45,9 @@
*
* The author can be reached at djurfeldt@nada.kth.se
* Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -66,10 +69,10 @@
#define scm_whash_create_handle(whash, key) scm_hash_fn_create_handle_x (whash, key, SCM_UNSPECIFIED, scm_ihashq, scm_sloppy_assq, 0)
#define scm_whash_lookup(whash, obj) scm_hash_fn_ref (whash, obj, SCM_BOOL_F, scm_ihashq, scm_sloppy_assq, 0)
#define scm_whash_insert(whash, key, obj) \
-{ \
+do { \
register SCM w = (whash); \
SCM_WHASHSET (w, scm_whash_create_handle (w, key), obj); \
-} \
+} while (0)
/* {Source properties}
@@ -92,7 +95,7 @@ typedef struct scm_srcprops_chunk
scm_srcprops srcprops[1];
} scm_srcprops_chunk;
-#define SRCPROPSP(p) (SCM_TYP16 (p) == scm_tc16_srcprops)
+#define SRCPROPSP(p) (SCM_NIMP(p) && (SCM_TYP16 (p) == scm_tc16_srcprops))
#define SRCPROPBRK(p) (SCM_BOOL((1L << 16) & SCM_CAR (p)))
#define SRCPROPPOS(p) ((scm_srcprops *) SCM_CDR (p))->pos
#define SRCPROPLINE(p) (SRCPROPPOS(p) >> 12)
diff --git a/libguile/stacks.c b/libguile/stacks.c
index 8b2a2e6ce..2f56ea662 100644
--- a/libguile/stacks.c
+++ b/libguile/stacks.c
@@ -233,7 +233,7 @@ get_applybody ()
}
#define NEXT_FRAME(iframe, n, quit) \
-{ \
+do { \
if (SCM_NIMP (iframe->source) \
&& SCM_MEMOIZED_EXP (iframe->source) == applybody) \
{ \
@@ -247,7 +247,7 @@ get_applybody ()
++iframe; \
if (--n == 0) \
goto quit; \
-} \
+} while (0)
/* Fill the scm_info_frame vector IFRAME with data from N stack frames
diff --git a/libguile/stacks.h b/libguile/stacks.h
index f92fa9a94..246e15183 100644
--- a/libguile/stacks.h
+++ b/libguile/stacks.h
@@ -45,6 +45,9 @@
*
* The author can be reached at djurfeldt@nada.kth.se
* Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -72,11 +75,11 @@ typedef struct scm_stack {
extern SCM scm_stack_type;
-#define SCM_STACKP(obj) (SCM_STRUCTP (obj) && SCM_STRUCT_VTABLE (obj) == scm_stack_type)
+#define SCM_STACKP(obj) (SCM_NIMP(obj) && \
+ SCM_STRUCTP (obj) && SCM_STRUCT_VTABLE (obj) == scm_stack_type)
#define SCM_STACK_LENGTH(stack) (SCM_STACK (stack) -> length)
#define SCM_FRAMEP(obj) (SCM_CONSP (obj) \
- && SCM_NIMP (SCM_CAR (obj)) \
&& SCM_STACKP (SCM_CAR (obj)) \
&& SCM_INUMP (SCM_CDR (obj))) \
diff --git a/libguile/strings.h b/libguile/strings.h
index 5f5334e13..279dd57e8 100644
--- a/libguile/strings.h
+++ b/libguile/strings.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -52,11 +55,11 @@
-#define SCM_STRINGP(x) (SCM_TYP7S(x)==scm_tc7_string)
+#define SCM_STRINGP(x) (SCM_NIMP(x) && (SCM_TYP7S(x)==scm_tc7_string))
#define SCM_NSTRINGP(x) (!SCM_STRINGP(x))
/* Is X a writable string (i.e., not a substring)? */
-#define SCM_RWSTRINGP(x) (SCM_TYP7(x) == scm_tc7_string)
+#define SCM_RWSTRINGP(x) (SCM_NIMP(x) && (SCM_TYP7(x) == scm_tc7_string))
#define SCM_NRWSTRINGP(x) (! SCM_RWSTRINGP (x))
diff --git a/libguile/struct.h b/libguile/struct.h
index 8b9dd679e..bfd894b65 100644
--- a/libguile/struct.h
+++ b/libguile/struct.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -74,7 +77,7 @@ typedef scm_sizet (*scm_struct_free_t) (SCM *vtable, SCM *data);
#define SCM_STRUCTF_LIGHT (1L << 31) /* Light representation
(no hidden words) */
-#define SCM_STRUCTP(X) (SCM_TYP3(X) == scm_tc3_cons_gloc)
+#define SCM_STRUCTP(X) (SCM_NIMP(X) && (SCM_TYP3(X) == scm_tc3_cons_gloc))
#define SCM_STRUCT_DATA(X) ((SCM*)(SCM_CDR(X)))
#define SCM_STRUCT_VTABLE_DATA(X) ((SCM *)(SCM_CAR(X) - 1))
#define SCM_STRUCT_LAYOUT(X) (SCM_STRUCT_VTABLE_DATA(X)[scm_vtable_index_layout])
diff --git a/libguile/symbols.h b/libguile/symbols.h
index deb53fbf7..a20d20a34 100644
--- a/libguile/symbols.h
+++ b/libguile/symbols.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -73,7 +76,7 @@ extern int scm_symhash_dim;
the slots? That's a good question; ask the author. I think it was
the cognac. */
-#define SCM_SYMBOLP(x) (SCM_TYP7S(x)==scm_tc7_ssymbol)
+#define SCM_SYMBOLP(x) (SCM_NIMP(x) && (SCM_TYP7S(x)==scm_tc7_ssymbol))
#define SCM_LENGTH(x) (((unsigned long)SCM_CAR(x))>>8)
#define SCM_LENGTH_MAX (0xffffffL)
#define SCM_SETLENGTH(x, v, t) SCM_SETCAR((x), ((v)<<8)+(t))
@@ -86,16 +89,16 @@ extern int scm_symhash_dim;
#define SCM_SYMBOL_PROPS(X) (SCM_SLOTS(X)[1])
#define SCM_SYMBOL_HASH(X) (*(unsigned long*)(&SCM_SLOTS(X)[2]))
-#define SCM_ROSTRINGP(x) ((SCM_TYP7S(x)==scm_tc7_string) \
- || (SCM_TYP7S(x) == scm_tc7_ssymbol))
-#define SCM_ROCHARS(x) ((SCM_TYP7(x) == scm_tc7_substring) \
+#define SCM_ROSTRINGP(x) (SCM_NIMP(x) && ((SCM_TYP7S(x)==scm_tc7_string) \
+ || (SCM_TYP7S(x) == scm_tc7_ssymbol)))
+#define SCM_ROCHARS(x) ((char *)((SCM_TYP7(x) == scm_tc7_substring) \
? SCM_INUM (SCM_CADR (x)) + SCM_CHARS (SCM_CDDR (x)) \
- : SCM_CHARS (x))
-#define SCM_ROUCHARS(x) ((SCM_TYP7(x) == scm_tc7_substring) \
+ : SCM_CHARS (x)))
+#define SCM_ROUCHARS(x) ((char *) ((SCM_TYP7(x) == scm_tc7_substring) \
? SCM_INUM (SCM_CADR (x)) + SCM_UCHARS (SCM_CDDR (x))\
- : SCM_UCHARS (x))
+ : SCM_UCHARS (x)))
#define SCM_ROLENGTH(x) SCM_LENGTH (x)
-#define SCM_SUBSTRP(x) ((SCM_TYP7(x) == scm_tc7_substring))
+#define SCM_SUBSTRP(x) (SCM_NIMP(x) && ((SCM_TYP7(x) == scm_tc7_substring)))
#define SCM_SUBSTR_STR(x) (SCM_CDDR (x))
#define SCM_SUBSTR_OFFSET(x) (SCM_CADR (x))
diff --git a/libguile/tags.h b/libguile/tags.h
index 68d5d638c..f717ac29f 100644
--- a/libguile/tags.h
+++ b/libguile/tags.h
@@ -264,8 +264,8 @@ typedef long SCM;
* stored in the SCM_CAR of a non-immediate object have a 1 in bit 1:
*/
-#define SCM_NCONSP(x) (1 & SCM_CAR(x))
-#define SCM_CONSP(x) (!SCM_NCONSP(x))
+#define SCM_NCONSP(x) (SCM_IMP(x) || (1 & SCM_CAR(x)))
+#define SCM_CONSP(x) (SCM_NIMP(x) && !(1 & SCM_CAR(x)))
/* SCM_ECONSP should be used instead of SCM_CONSP at places where GLOCS
diff --git a/libguile/threads.h b/libguile/threads.h
index 2c937480d..53255048d 100644
--- a/libguile/threads.h
+++ b/libguile/threads.h
@@ -43,6 +43,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -53,13 +56,13 @@ extern long scm_tc16_thread;
extern long scm_tc16_mutex;
extern long scm_tc16_condvar;
-#define SCM_THREADP(obj) (scm_tc16_thread == SCM_TYP16 (obj))
+#define SCM_THREADP(obj) (SCM_NIMP(obj) && (scm_tc16_thread == SCM_TYP16 (obj)))
#define SCM_THREAD_DATA(obj) ((void *) SCM_CDR (obj))
-#define SCM_MUTEXP(obj) (scm_tc16_mutex == SCM_TYP16 (obj))
+#define SCM_MUTEXP(obj) (SCM_NIMP(obj) && (scm_tc16_mutex == SCM_TYP16 (obj)))
#define SCM_MUTEX_DATA(obj) ((void *) SCM_CDR (obj))
-#define SCM_CONDVARP(obj) (scm_tc16_condvar == SCM_TYP16 (obj))
+#define SCM_CONDVARP(obj) (SCM_NIMP(obj) && (scm_tc16_condvar == SCM_TYP16 (obj)))
#define SCM_CONDVAR_DATA(obj) ((void *) SCM_CDR (obj))
/* Initialize implementation specific details of the threads support */
diff --git a/libguile/throw.c b/libguile/throw.c
index 3a19ffde0..59e4ad9d6 100644
--- a/libguile/throw.c
+++ b/libguile/throw.c
@@ -68,7 +68,7 @@
/* the jump buffer data structure */
static int scm_tc16_jmpbuffer;
-#define SCM_JMPBUFP(O) (SCM_TYP16(O) == scm_tc16_jmpbuffer)
+#define SCM_JMPBUFP(O) (SCM_NIMP(O) && (SCM_TYP16(O) == scm_tc16_jmpbuffer))
#define JBACTIVE(O) (SCM_CAR (O) & (1L << 16L))
#define ACTIVATEJB(O) (SCM_SETOR_CAR (O, (1L << 16L)))
#define DEACTIVATEJB(O) (SCM_SETAND_CAR (O, ~(1L << 16L)))
diff --git a/libguile/unif.h b/libguile/unif.h
index 26c47a286..6d2cdda2a 100644
--- a/libguile/unif.h
+++ b/libguile/unif.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -73,7 +76,7 @@ typedef struct scm_array_dim
extern long scm_tc16_array;
-#define SCM_ARRAYP(a) (scm_tc16_array==SCM_TYP16(a))
+#define SCM_ARRAYP(a) (SCM_NIMP(a) && (scm_tc16_array==SCM_TYP16(a)))
#define SCM_ARRAY_NDIM(x) ((scm_sizet)(SCM_CAR(x)>>17))
#define SCM_ARRAY_CONTIGUOUS 0x10000
#define SCM_ARRAY_CONTP(x) (SCM_ARRAY_CONTIGUOUS & (int)SCM_CAR(x))
diff --git a/libguile/variable.h b/libguile/variable.h
index b63922b2e..21cc482c3 100644
--- a/libguile/variable.h
+++ b/libguile/variable.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -53,7 +56,7 @@
extern int scm_tc16_variable;
#define SCM_VARVCELL(V) SCM_CDR(V)
-#define SCM_VARIABLEP(X) (scm_tc16_variable == SCM_CAR(X))
+#define SCM_VARIABLEP(X) (SCM_NIMP(X) && (scm_tc16_variable == SCM_CAR(X)))
#define SCM_UDVARIABLEP(X) (SCM_VARIABLEP(X) && SCM_UNBNDP (SCM_CDR (SCM_VARVCELL (X))))
#define SCM_DEFVARIABLEP(X) (SCM_VARIABLEP(X) && !SCM_UNBNDP (SCM_CDR (SCM_VARVCELL (X))))
diff --git a/libguile/vectors.h b/libguile/vectors.h
index b834f9fe9..75a91cf6d 100644
--- a/libguile/vectors.h
+++ b/libguile/vectors.h
@@ -42,13 +42,16 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
-#define SCM_VECTORP(x) (SCM_TYP7S(x)==scm_tc7_vector)
+#define SCM_VECTORP(x) (SCM_NIMP(x) && (SCM_TYP7S(x)==scm_tc7_vector))
#define SCM_NVECTORP(x) (!SCM_VECTORP(x))
#define SCM_VELTS(x) ((SCM *)SCM_CDR(x))
#define SCM_SETVELTS SCM_SETCDR
diff --git a/libguile/weaks.h b/libguile/weaks.h
index cedfbc6c0..c31b66f65 100644
--- a/libguile/weaks.h
+++ b/libguile/weaks.h
@@ -42,6 +42,9 @@
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/__scm.h"
@@ -49,7 +52,7 @@
-#define SCM_WVECTP(x) (SCM_TYP7(x)==scm_tc7_wvect)
+#define SCM_WVECTP(x) (SCM_NIMP(x) && (SCM_TYP7(x)==scm_tc7_wvect))
#define SCM_IS_WHVEC(X) (SCM_VELTS(X)[-1] == 1)
#define SCM_IS_WHVEC_V(X) (SCM_VELTS(X)[-1] == 2)
#define SCM_IS_WHVEC_B(X) (SCM_VELTS(X)[-1] == 3)