diff options
-rw-r--r-- | libguile/strings.c | 3 | ||||
-rw-r--r-- | libguile/symbols.h | 7 | ||||
-rw-r--r-- | libguile/tags.h | 34 |
3 files changed, 23 insertions, 21 deletions
diff --git a/libguile/strings.c b/libguile/strings.c index dc7270f3c..3582bac12 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -370,7 +370,8 @@ scm_make_shared_substring (str, frm, to) f = SCM_INUM (frm); t = SCM_INUM (to); SCM_ASSERT ((f >= 0), frm, SCM_OUTOFRANGE, s_make_shared_substring); - SCM_ASSERT ((f <= t) && (t <= SCM_ROLENGTH (str)), to, SCM_OUTOFRANGE, s_make_shared_substring); + SCM_ASSERT ((f <= t) && (t <= SCM_ROLENGTH (str)), to, SCM_OUTOFRANGE, + s_make_shared_substring); SCM_NEWCELL (answer); SCM_NEWCELL (len_str); diff --git a/libguile/symbols.h b/libguile/symbols.h index 6f335c2c5..e154eb0d0 100644 --- a/libguile/symbols.h +++ b/libguile/symbols.h @@ -86,15 +86,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_ROSTRINGP(x) ((SCM_TYP7S(x)==scm_tc7_string) \ + || (SCM_TYP7S(x) == scm_tc7_ssymbol)) #define SCM_ROCHARS(x) ((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_INUM (SCM_CADR (x)) + SCM_UCHARS (SCM_CDDR (x)) \ + ? SCM_INUM (SCM_CADR (x)) + SCM_UCHARS (SCM_CDDR (x))\ : SCM_UCHARS (x)) #define SCM_ROLENGTH(x) SCM_LENGTH (x) -#define SCM_SUBSTRP(x) ((SCM_TYP7S(x) == scm_tc7_substring)) +#define SCM_SUBSTRP(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 6497d87e2..d41795b36 100644 --- a/libguile/tags.h +++ b/libguile/tags.h @@ -190,7 +190,7 @@ typedef long SCM; * gloc ..........SCM vcell..........001 ...........SCM cdr.............G * struct ..........void * type........001 ...........void * data.........G * closure ..........SCM code...........011 ...........SCM env.............G - * tc7 .........long length....GxxxD1S1 ..........void *data............ + * tc7 .........long length....Gxxxx1S1 ..........void *data............ * * * @@ -214,13 +214,13 @@ typedef long SCM; * for that type. * * Sometimes we choose the bottom seven bits carefully, - * so that the 4- and 1-valued bits (called the D and S - * bits) can be masked off to reveal a common type. + * so that the 2-valued bit (called S bit) can be masked + * off to reveal a common type. * * TYP7S(X) returns TYP7, but masking out the option bit S. * - * For example, all strings have 001 in the 'xxx' bits in - * the diagram above, the D bit says whether it's a + * For example, all strings have 0010 in the 'xxxx' bits + * in the diagram above, the S bit says whether it's a * substring. * * for example: @@ -228,9 +228,9 @@ typedef long SCM; * scm_tc7_string = G0010101 * scm_tc7_substring = G0010111 * - * TYP7S turns all string tags into tc7_string; thus, + * TYP7S turns both string tags into tc7_string; thus, * testing TYP7S against tc7_string is a quick way to - * test for any kind of string. + * test for any kind of string, shared or unshared. * * Some TC7 types are subdivided into 256 subtypes giving * rise to the macros: @@ -250,14 +250,14 @@ typedef long SCM; /* {Non-immediate values.} * * If X is non-immediate, it is necessary to look at SCM_CAR (X) to - * figure out Xs type. X may be a cons pair, in which case the - * value SCM_CAR (x) will be either an immediate or non-immediate value. - * X may be something other than a cons pair, in which case the value SCM_CAR (x) - * will be a non-object value. - * - * All immediates and non-immediates have a 0 in bit 0. We additionally preserve - * the invariant that all non-object values stored in the SCM_CAR of a non-immediate - * object have a 1 in bit 1: + * figure out Xs type. X may be a cons pair, in which case the value + * SCM_CAR (x) will be either an immediate or non-immediate value. X + * may be something other than a cons pair, in which case the value + * SCM_CAR (x) will be a non-object value. + * + * All immediates and non-immediates have a 0 in bit 0. We + * additionally preserve the invariant that all non-object values + * stored in the SCM_CAR of a non-immediate object have a 1 in bit 1: */ #define SCM_NCONSP(x) (1 & (int)SCM_CAR(x)) @@ -299,8 +299,8 @@ typedef long SCM; */ -#define SCM_TYP7(x) (0x7f & (int)SCM_CAR(x)) -#define SCM_TYP7S(x) (0x7d & (int)SCM_CAR(x)) +#define SCM_TYP7(x) ((int)SCM_CAR(x) & 0x7f) +#define SCM_TYP7S(x) ((int)SCM_CAR(x) & (0x7f & ~2)) #define SCM_TYP16(x) (0xffff & (int)SCM_CAR(x)) |