mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-09 15:10:29 +02:00
* strings.h: If GUILE_EXPERIMENTAL_BIG_STRINGS is defined, use
different definitions for SCM_STRING_MAX_LENGTH, SCM_STRING_LENGTH and SCM_SET_STRING_LENGTH, and add new convenience macro SCM_SET_SUBSTRING_LENGTH. * strings.c (scm_makstr, scm_take_str, scm_allocate_string, scm_make_shared_substring): Allocate a double cell for a string, if GUILE_EXPERIMENTAL_BIG_STRINGS is defined.
This commit is contained in:
parent
16c2ec02fa
commit
6868a8e68f
3 changed files with 64 additions and 0 deletions
|
@ -1,3 +1,22 @@
|
|||
2006-11-17 Neil Jerram <neil@ossau.uklinux.net>
|
||||
|
||||
Integration of patch from Daniel Ridge to allow strings in 1.6.x
|
||||
to have length up to 2^32 - 1, instead of 2^24 - 1 as currently.
|
||||
All changes are subject to #ifdef GUILE_EXPERIMENTAL_BIG_STRINGS;
|
||||
GUILE_EXPERIMENTAL_BIG_STRINGS is _not_ defined by default, and we
|
||||
have no intention of changing this within the official 1.6.x
|
||||
series. The only reason for integrating this is as a convenience
|
||||
for the contributor, as and when we make further 1.6.x releases.
|
||||
|
||||
* strings.h: If GUILE_EXPERIMENTAL_BIG_STRINGS is defined, use
|
||||
different definitions for SCM_STRING_MAX_LENGTH, SCM_STRING_LENGTH
|
||||
and SCM_SET_STRING_LENGTH, and add new convenience macro
|
||||
SCM_SET_SUBSTRING_LENGTH.
|
||||
|
||||
* strings.c (scm_makstr, scm_take_str, scm_allocate_string,
|
||||
scm_make_shared_substring): Allocate a double cell for a string,
|
||||
if GUILE_EXPERIMENTAL_BIG_STRINGS is defined.
|
||||
|
||||
2006-10-03 Kevin Ryde <user42@zip.com.au>
|
||||
|
||||
* eval.c (SCM_APPLY): For scm_tc7_subr_2o, throw wrong-num-args on 0
|
||||
|
|
|
@ -131,7 +131,11 @@ scm_makstr (size_t len, int dummy)
|
|||
mem = (char *) scm_must_malloc (len + 1, FUNC_NAME);
|
||||
mem[len] = 0;
|
||||
|
||||
#ifndef GUILE_EXPERIMENTAL_BIG_STRINGS
|
||||
SCM_NEWCELL (s);
|
||||
#else
|
||||
SCM_NEWCELL2 (s);
|
||||
#endif
|
||||
SCM_SET_STRING_CHARS (s, mem);
|
||||
SCM_SET_STRING_LENGTH (s, len);
|
||||
|
||||
|
@ -173,7 +177,11 @@ scm_take_str (char *s, size_t len)
|
|||
|
||||
SCM_ASSERT_RANGE (2, scm_ulong2num (len), len <= SCM_STRING_MAX_LENGTH);
|
||||
|
||||
#ifndef GUILE_EXPERIMENTAL_BIG_STRINGS
|
||||
SCM_NEWCELL (answer);
|
||||
#else
|
||||
SCM_NEWCELL2 (answer);
|
||||
#endif
|
||||
SCM_SET_STRING_CHARS (answer, s);
|
||||
SCM_SET_STRING_LENGTH (answer, len);
|
||||
scm_done_malloc (len + 1);
|
||||
|
@ -241,7 +249,11 @@ scm_allocate_string (size_t len)
|
|||
mem = (char *) scm_must_malloc (len + 1, FUNC_NAME);
|
||||
mem[len] = 0;
|
||||
|
||||
#ifndef GUILE_EXPERIMENTAL_BIG_STRINGS
|
||||
SCM_NEWCELL (s);
|
||||
#else
|
||||
SCM_NEWCELL2 (s);
|
||||
#endif
|
||||
SCM_SET_STRING_CHARS (s, mem);
|
||||
SCM_SET_STRING_LENGTH (s, len);
|
||||
|
||||
|
@ -415,13 +427,26 @@ SCM_DEFINE (scm_make_shared_substring, "make-shared-substring", 1, 2, 0,
|
|||
|
||||
SCM_VALIDATE_ROSTRING (1,str);
|
||||
SCM_VALIDATE_INUM_DEF_COPY (2,start,0,f);
|
||||
#ifndef GUILE_EXPERIMENTAL_BIG_STRINGS
|
||||
SCM_VALIDATE_INUM_DEF_COPY (3,end,SCM_ROLENGTH(str),t);
|
||||
#else
|
||||
SCM_VALIDATE_INUM_DEF_COPY (3,end,SCM_STRING_LENGTH(str),t);
|
||||
#endif
|
||||
|
||||
SCM_ASSERT_RANGE (2,start,(f >= 0));
|
||||
#ifndef GUILE_EXPERIMENTAL_BIG_STRINGS
|
||||
SCM_ASSERT_RANGE (3,end, (f <= t) && (t <= SCM_ROLENGTH (str)));
|
||||
#else
|
||||
SCM_ASSERT_RANGE (3,end, (f <= t) && (t <= SCM_STRING_LENGTH (str)));
|
||||
#endif
|
||||
|
||||
#ifndef GUILE_EXPERIMENTAL_BIG_STRINGS
|
||||
SCM_NEWCELL (answer);
|
||||
SCM_NEWCELL (len_str);
|
||||
#else
|
||||
SCM_NEWCELL2 (answer);
|
||||
SCM_NEWCELL2 (len_str);
|
||||
#endif
|
||||
|
||||
SCM_DEFER_INTS;
|
||||
if (SCM_SUBSTRP (str))
|
||||
|
@ -433,14 +458,22 @@ SCM_DEFINE (scm_make_shared_substring, "make-shared-substring", 1, 2, 0,
|
|||
SCM_SETCAR (len_str, SCM_MAKINUM (f));
|
||||
SCM_SETCDR (len_str, SCM_SUBSTR_STR (str));
|
||||
SCM_SETCDR (answer, len_str);
|
||||
#ifndef GUILE_EXPERIMENTAL_BIG_STRINGS
|
||||
SCM_SETLENGTH (answer, t - f, scm_tc7_substring);
|
||||
#else
|
||||
SCM_SET_SUBSTRING_LENGTH (answer, t - f);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
SCM_SETCAR (len_str, SCM_MAKINUM (f));
|
||||
SCM_SETCDR (len_str, str);
|
||||
SCM_SETCDR (answer, len_str);
|
||||
#ifndef GUILE_EXPERIMENTAL_BIG_STRINGS
|
||||
SCM_SETLENGTH (answer, t - f, scm_tc7_substring);
|
||||
#else
|
||||
SCM_SET_SUBSTRING_LENGTH (answer, t - f);
|
||||
#endif
|
||||
}
|
||||
SCM_ALLOW_INTS;
|
||||
return answer;
|
||||
|
|
|
@ -55,10 +55,22 @@
|
|||
#define SCM_STRING_CHARS(x) ((char *) (SCM_CELL_WORD_1 (x)))
|
||||
#endif
|
||||
#define SCM_SET_STRING_CHARS(s, c) (SCM_SET_CELL_WORD_1 ((s), (c)))
|
||||
|
||||
#ifndef GUILE_EXPERIMENTAL_BIG_STRINGS
|
||||
|
||||
#define SCM_STRING_MAX_LENGTH ((1UL << 24) - 1UL)
|
||||
#define SCM_STRING_LENGTH(x) ((size_t) (SCM_CELL_WORD_0 (x) >> 8))
|
||||
#define SCM_SET_STRING_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), (((long) (l)) << 8) + scm_tc7_string))
|
||||
|
||||
#else
|
||||
|
||||
#define SCM_STRING_MAX_LENGTH ((1UL << (SCM_C_BVEC_LIMB_BITS)) - 1UL)
|
||||
#define SCM_STRING_LENGTH(x) ((size_t) (SCM_CELL_WORD_2 (x)))
|
||||
#define SCM_SET_STRING_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), scm_tc7_string), SCM_SET_CELL_WORD_2 ((s), (((long) (l)))))
|
||||
#define SCM_SET_SUBSTRING_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), scm_tc7_substring), SCM_SET_CELL_WORD_2 ((s), (((long) (l)))))
|
||||
|
||||
#endif
|
||||
|
||||
#define SCM_STRING_COERCE_0TERMINATION_X(x) \
|
||||
{ if (!SCM_IMP (x) && (SCM_TYP7 (x) == scm_tc7_substring)) \
|
||||
x = scm_mem2string (SCM_STRING_CHARS (x), SCM_STRING_LENGTH (x)); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue