1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-22 04:30:19 +02:00

Minor problems with substring-related tag changes.

* symbols.h (SCM_SUBSTRP): Don't mask off the S bit; that's
exactly what we want to leave in to detect substrings.
(SCM_ROSTRINGP, ROUCHARS): Formatting tweaks.
* tags.h: Fix diagrams and comments describing the S tag bit;
remove vestigial remarks about the D tag bit.
(SCM_TYP7, SCM_TYP7S): Rephrased for readability.
* strings.c: Formatting tweaks.
This commit is contained in:
Jim Blandy 1997-10-25 06:53:47 +00:00
parent 01cddfc1e8
commit c2cb25006b
3 changed files with 22 additions and 20 deletions

View file

@ -370,7 +370,8 @@ scm_make_shared_substring (str, frm, to)
f = SCM_INUM (frm); f = SCM_INUM (frm);
t = SCM_INUM (to); t = SCM_INUM (to);
SCM_ASSERT ((f >= 0), frm, SCM_OUTOFRANGE, s_make_shared_substring); 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 (answer);
SCM_NEWCELL (len_str); SCM_NEWCELL (len_str);

View file

@ -86,15 +86,16 @@ extern int scm_symhash_dim;
#define SCM_SYMBOL_PROPS(X) (SCM_SLOTS(X)[1]) #define SCM_SYMBOL_PROPS(X) (SCM_SLOTS(X)[1])
#define SCM_SYMBOL_HASH(X) (*(unsigned long*)(&SCM_SLOTS(X)[2])) #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) \ #define SCM_ROCHARS(x) ((SCM_TYP7(x) == scm_tc7_substring) \
? SCM_INUM (SCM_CADR (x)) + SCM_CHARS (SCM_CDDR (x)) \ ? SCM_INUM (SCM_CADR (x)) + SCM_CHARS (SCM_CDDR (x)) \
: SCM_CHARS (x)) : SCM_CHARS (x))
#define SCM_ROUCHARS(x) ((SCM_TYP7(x) == scm_tc7_substring) \ #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)) : SCM_UCHARS (x))
#define SCM_ROLENGTH(x) SCM_LENGTH (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_STR(x) (SCM_CDDR (x))
#define SCM_SUBSTR_OFFSET(x) (SCM_CADR (x)) #define SCM_SUBSTR_OFFSET(x) (SCM_CADR (x))

View file

@ -190,7 +190,7 @@ typedef long SCM;
* gloc ..........SCM vcell..........001 ...........SCM cdr.............G * gloc ..........SCM vcell..........001 ...........SCM cdr.............G
* struct ..........void * type........001 ...........void * data.........G * struct ..........void * type........001 ...........void * data.........G
* closure ..........SCM code...........011 ...........SCM env.............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. * for that type.
* *
* Sometimes we choose the bottom seven bits carefully, * Sometimes we choose the bottom seven bits carefully,
* so that the 4- and 1-valued bits (called the D and S * so that the 2-valued bit (called S bit) can be masked
* bits) can be masked off to reveal a common type. * off to reveal a common type.
* *
* TYP7S(X) returns TYP7, but masking out the option bit S. * TYP7S(X) returns TYP7, but masking out the option bit S.
* *
* For example, all strings have 001 in the 'xxx' bits in * For example, all strings have 0010 in the 'xxxx' bits
* the diagram above, the D bit says whether it's a * in the diagram above, the S bit says whether it's a
* substring. * substring.
* *
* for example: * for example:
@ -228,9 +228,9 @@ typedef long SCM;
* scm_tc7_string = G0010101 * scm_tc7_string = G0010101
* scm_tc7_substring = G0010111 * 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 * 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 * Some TC7 types are subdivided into 256 subtypes giving
* rise to the macros: * rise to the macros:
@ -250,14 +250,14 @@ typedef long SCM;
/* {Non-immediate values.} /* {Non-immediate values.}
* *
* If X is non-immediate, it is necessary to look at SCM_CAR (X) to * 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 * figure out Xs type. X may be a cons pair, in which case the value
* value SCM_CAR (x) will be either an immediate or non-immediate value. * SCM_CAR (x) will be either an immediate or non-immediate value. X
* X may be something other than a cons pair, in which case the value SCM_CAR (x) * may be something other than a cons pair, in which case the value
* will be a non-object value. * SCM_CAR (x) will be a non-object value.
* *
* All immediates and non-immediates have a 0 in bit 0. We additionally preserve * All immediates and non-immediates have a 0 in bit 0. We
* the invariant that all non-object values stored in the SCM_CAR of a non-immediate * additionally preserve the invariant that all non-object values
* object have a 1 in bit 1: * 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)) #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_TYP7(x) ((int)SCM_CAR(x) & 0x7f)
#define SCM_TYP7S(x) (0x7d & (int)SCM_CAR(x)) #define SCM_TYP7S(x) ((int)SCM_CAR(x) & (0x7f & ~2))
#define SCM_TYP16(x) (0xffff & (int)SCM_CAR(x)) #define SCM_TYP16(x) (0xffff & (int)SCM_CAR(x))