1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-16 16:50:21 +02:00

* Some more work to get rid of SCM_LENGTH

* Eliminated some cell type bit fiddling
* Various minor changes
This commit is contained in:
Dirk Herrmann 2000-10-25 11:01:03 +00:00
parent 31535422f5
commit d1ca2c6423
25 changed files with 129 additions and 65 deletions

5
NEWS
View file

@ -140,11 +140,14 @@ of this variable is (and has been) not fully safe anyway.
** Deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL, ** Deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL,
SCM_INT_SIGNAL, SCM_FPE_SIGNAL, SCM_BUS_SIGNAL, SCM_SEGV_SIGNAL, SCM_INT_SIGNAL, SCM_FPE_SIGNAL, SCM_BUS_SIGNAL, SCM_SEGV_SIGNAL,
SCM_ALRM_SIGNAL, SCM_GC_SIGNAL, SCM_TICK_SIGNAL, SCM_SIG_ORD, SCM_ALRM_SIGNAL, SCM_GC_SIGNAL, SCM_TICK_SIGNAL, SCM_SIG_ORD,
SCM_ORD_SIG, SCM_NUM_SIGS, SCM_SYMBOL_SLOTS, SCM_SLOTS, SCM_SLOPPY_STRINGP SCM_ORD_SIG, SCM_NUM_SIGS, SCM_SYMBOL_SLOTS, SCM_SLOTS, SCM_SLOPPY_STRINGP,
SCM_VALIDATE_STRINGORSUBSTR, SCM_FREEP, SCM_NFREEP
Use SCM_ASSERT_RANGE or SCM_VALIDATE_XXX_RANGE instead of SCM_OUTOFRANGE. Use SCM_ASSERT_RANGE or SCM_VALIDATE_XXX_RANGE instead of SCM_OUTOFRANGE.
Use scm_memory_error instead of SCM_NALLOC. Use scm_memory_error instead of SCM_NALLOC.
Use SCM_STRINGP instead of SCM_SLOPPY_STRINGP. Use SCM_STRINGP instead of SCM_SLOPPY_STRINGP.
Use SCM_VALIDATE_STRING instead of SCM_VALIDATE_STRINGORSUBSTR.
Use SCM_FREE_CELL_P instead of SCM_FREEP/SCM_NFREEP
** Removed function: scm_struct_init ** Removed function: scm_struct_init

View file

@ -9,11 +9,6 @@ for."
* Deprecate `read-only-string?'. * Deprecate `read-only-string?'.
Before releasing the next version of libguile which is not binary compatible
with the one released with 1.4:
- remove struct members system_transformer and top_level_lookup_closure_var
from struct scm_root_state in root.h.
After signal handling and threading have been fixed: After signal handling and threading have been fixed:
- remove the code corresponding to GUILE_OLD_ASYNC_CLICK and the corresponding - remove the code corresponding to GUILE_OLD_ASYNC_CLICK and the corresponding
GUILE_OLD_ASYNC_CLICK macro. GUILE_OLD_ASYNC_CLICK macro.
@ -50,7 +45,8 @@ In release 1.6:
- remove deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL, - remove deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL,
SCM_INT_SIGNAL, SCM_FPE_SIGNAL, SCM_BUS_SIGNAL, SCM_SEGV_SIGNAL, SCM_INT_SIGNAL, SCM_FPE_SIGNAL, SCM_BUS_SIGNAL, SCM_SEGV_SIGNAL,
SCM_ALRM_SIGNAL, SCM_GC_SIGNAL, SCM_TICK_SIGNAL, SCM_SIG_ORD, SCM_ALRM_SIGNAL, SCM_GC_SIGNAL, SCM_TICK_SIGNAL, SCM_SIG_ORD,
SCM_ORD_SIG, SCM_NUM_SIGS, SCM_SLOPPY_STRINGP SCM_ORD_SIG, SCM_NUM_SIGS, SCM_SLOPPY_STRINGP, SCM_VALIDATE_STRINGORSUBSTR,
SCM_FREEP, SCM_NFREEP
- remove function scm_call_catching_errors - remove function scm_call_catching_errors
(replaced by catch functions from throw.[ch]) (replaced by catch functions from throw.[ch])
- remove support for "#&" reader syntax in (ice-9 optargs). - remove support for "#&" reader syntax in (ice-9 optargs).

View file

@ -1,3 +1,53 @@
2000-10-25 Dirk Herrmann <D.Herrmann@tu-bs.de>
* alist.c (scm_assq_ref): Add a suggestion about how to deal with
this function when the API gets reviewed.
* async.c (SET_ASYNC_GOT_IT): Use SCM_TYP16 instead of doing bit
operations directly.
* dynl.c (scm_coerce_rostring), filesys.c (scm_link,
scm_copy_file), fports (scm_open_file), hash.c (scm_hasher),
posix.c (scm_getpwuid), print.c (scm_iprin1), simpos.c
(scm_system), strings.c (scm_string_ref, scm_substring,
scm_string_append), strop.c (scm_string_copy), struct.c
(scm_make_struct_layout), symbols.c (scm_gensym, scm_gentemp),
symbols.h (SCM_COERCE_SUBSTR): Use SCM_STRING_LENGTH instead of
SCM_ROLENGTH if the object is known to be a string or substring.
* eval.c (scm_lookupcar): Use SCM_ITAG7 instead of doing bit
operations directly.
* filesys.c (scm_dirname, scm_basename): Don't create shared
substrings as these are going to disappear from guile.
* gc.c (scm_gc_sweep): Use SCM_UVECTOR_LENGTH instead of
SCM_HUGE_LENGTH. (The SCM_HUGE_LENGTH mechanism does not work
correctly anyway.)
* gc.h (SCM_FREEP, SCM_NFREEP): Deprecated.
* read.c (scm_flush_ws): Don't compare SCM values directly.
* root.c (scm_make_root), root.h (scm_root_state): Removed
system_transformer and top_level_lookup_closure_var from struct.
(Since eval is now R5RS, binary compatibility is not granted
anyway.)
* simpos.c (scm_system): Fix condition.
* strings.c (scm_string_length, scm_string_ref, scm_substring,
scm_string_append), strop.c (scm_string_copy), struct.c
(scm_make_struct_layout, scm_make_vtable_vtable), symbols.c
(scm_gensym, scm_gentemp): Replace SCM_VALIDATE_STRINGORSUBSTR
with SCM_VALIDATE_STRING, since they do the same thing.
* strings.h (scm_make_shared_substring): Deprecated.
* tags.h (SCM_ITAG7): Added.
* validated.h (SCM_VALIDATE_STRINGORSUBSTR): Deprecated.
2000-10-20 Marius Vollmer <mvo@zagadka.ping.de> 2000-10-20 Marius Vollmer <mvo@zagadka.ping.de>
* init.c (scm_init_guile_1, invoke_main_func): Call * init.c (scm_init_guile_1, invoke_main_func): Call

View file

@ -207,6 +207,18 @@ SCM_DEFINE (scm_assoc, "assoc", 2, 0, 0,
/* Dirk:API2.0:: We should not return #f if the key was not found. In the
* current solution we can not distinguish between finding a (key . #f) pair
* and not finding the key at all.
*
* Possible alternative solutions:
* 1) Remove assq-ref from the API: assq is sufficient.
* 2) Signal an error (what error type?) if the key is not found.
* 3) provide an additional 'default' parameter.
* 3.1) The default parameter is mandatory.
* 3.2) The default parameter is optional, but if no default is given and
* the key is not found, signal an error (what error type?).
*/
SCM_DEFINE (scm_assq_ref, "assq-ref", 2, 0, 0, SCM_DEFINE (scm_assq_ref, "assq-ref", 2, 0, 0,
(SCM alist, SCM key), (SCM alist, SCM key),
"@deffnx primitive assv-ref alist key\n" "@deffnx primitive assv-ref alist key\n"

View file

@ -121,7 +121,7 @@ static long tc16_async;
#define VALIDATE_ASYNC(pos,a) SCM_MAKE_VALIDATE(pos, a, ASYNCP) #define VALIDATE_ASYNC(pos,a) SCM_MAKE_VALIDATE(pos, a, ASYNCP)
#define ASYNC_GOT_IT(X) (SCM_CELL_WORD_0 (X) >> 16) #define ASYNC_GOT_IT(X) (SCM_CELL_WORD_0 (X) >> 16)
#define SET_ASYNC_GOT_IT(X, V) (SCM_SET_CELL_WORD_0 (X, (SCM_CELL_WORD_0 (X) & ((1 << 16) - 1)) | ((V) << 16))) #define SET_ASYNC_GOT_IT(X, V) (SCM_SET_CELL_WORD_0 ((X), SCM_TYP16 (X) | ((V) << 16)))
#define ASYNC_THUNK(X) SCM_CELL_OBJECT_1 (X) #define ASYNC_THUNK(X) SCM_CELL_OBJECT_1 (X)

View file

@ -127,7 +127,7 @@ scm_coerce_rostring (SCM rostr,const char *subr,int argn)
{ {
SCM_ASSERT (SCM_ROSTRINGP (rostr), rostr, argn, subr); SCM_ASSERT (SCM_ROSTRINGP (rostr), rostr, argn, subr);
if (SCM_SUBSTRP (rostr)) if (SCM_SUBSTRP (rostr))
rostr = scm_makfromstr (SCM_ROCHARS (rostr), SCM_ROLENGTH (rostr), 0); rostr = scm_makfromstr (SCM_ROCHARS (rostr), SCM_STRING_LENGTH (rostr), 0);
return rostr; return rostr;
} }

View file

@ -370,7 +370,7 @@ scm_lookupcar (SCM vloc, SCM genv, int check)
if (SCM_ITAG3 (var) == scm_tc3_cons_gloc) if (SCM_ITAG3 (var) == scm_tc3_cons_gloc)
return SCM_GLOC_VAL_LOC (var); return SCM_GLOC_VAL_LOC (var);
#ifdef MEMOIZE_LOCALS #ifdef MEMOIZE_LOCALS
if ((SCM_UNPACK (var) & 127) == (127 & SCM_UNPACK (SCM_ILOC00))) if (SCM_ITAG7 (var) == SCM_ITAG7 (SCM_ILOC00))
return scm_ilookup (var, genv); return scm_ilookup (var, genv);
#endif #endif
/* We can't cope with anything else than glocs and ilocs. When /* We can't cope with anything else than glocs and ilocs. When

View file

@ -547,11 +547,11 @@ SCM_DEFINE (scm_link, "link", 2, 0, 0,
SCM_VALIDATE_ROSTRING (1,oldpath); SCM_VALIDATE_ROSTRING (1,oldpath);
if (SCM_SUBSTRP (oldpath)) if (SCM_SUBSTRP (oldpath))
oldpath = scm_makfromstr (SCM_ROCHARS (oldpath), oldpath = scm_makfromstr (SCM_ROCHARS (oldpath),
SCM_ROLENGTH (oldpath), 0); SCM_STRING_LENGTH (oldpath), 0);
SCM_VALIDATE_ROSTRING (2,newpath); SCM_VALIDATE_ROSTRING (2,newpath);
if (SCM_SUBSTRP (newpath)) if (SCM_SUBSTRP (newpath))
newpath = scm_makfromstr (SCM_ROCHARS (newpath), newpath = scm_makfromstr (SCM_ROCHARS (newpath),
SCM_ROLENGTH (newpath), 0); SCM_STRING_LENGTH (newpath), 0);
SCM_SYSCALL (val = link (SCM_ROCHARS (oldpath), SCM_ROCHARS (newpath))); SCM_SYSCALL (val = link (SCM_ROCHARS (oldpath), SCM_ROCHARS (newpath)));
if (val != 0) if (val != 0)
SCM_SYSERROR; SCM_SYSERROR;
@ -1289,10 +1289,10 @@ SCM_DEFINE (scm_copy_file, "copy-file", 2, 0, 0,
SCM_VALIDATE_ROSTRING (1,oldfile); SCM_VALIDATE_ROSTRING (1,oldfile);
if (SCM_SUBSTRP (oldfile)) if (SCM_SUBSTRP (oldfile))
oldfile = scm_makfromstr (SCM_ROCHARS (oldfile), SCM_ROLENGTH (oldfile), 0); oldfile = scm_makfromstr (SCM_ROCHARS (oldfile), SCM_STRING_LENGTH (oldfile), 0);
SCM_VALIDATE_ROSTRING (2,newfile); SCM_VALIDATE_ROSTRING (2,newfile);
if (SCM_SUBSTRP (newfile)) if (SCM_SUBSTRP (newfile))
newfile = scm_makfromstr (SCM_ROCHARS (newfile), SCM_ROLENGTH (newfile), 0); newfile = scm_makfromstr (SCM_ROCHARS (newfile), SCM_STRING_LENGTH (newfile), 0);
if (stat (SCM_ROCHARS (oldfile), &oldstat) == -1) if (stat (SCM_ROCHARS (oldfile), &oldstat) == -1)
SCM_SYSERROR; SCM_SYSERROR;
oldfd = open (SCM_ROCHARS (oldfile), O_RDONLY); oldfd = open (SCM_ROCHARS (oldfile), O_RDONLY);
@ -1345,12 +1345,12 @@ SCM_DEFINE (scm_dirname, "dirname", 1, 0, 0,
if (i < 0) if (i < 0)
{ {
if (len > 0 && s[0] == '/') if (len > 0 && s[0] == '/')
return scm_make_shared_substring (filename, SCM_INUM0, SCM_MAKINUM (1)); return scm_substring (filename, SCM_INUM0, SCM_MAKINUM (1));
else else
return scm_dot_string; return scm_dot_string;
} }
else else
return scm_make_shared_substring (filename, SCM_INUM0, SCM_MAKINUM (i + 1)); return scm_substring (filename, SCM_INUM0, SCM_MAKINUM (i + 1));
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -1384,14 +1384,12 @@ SCM_DEFINE (scm_basename, "basename", 1, 1, 0,
if (i == end) if (i == end)
{ {
if (len > 0 && f[0] == '/') if (len > 0 && f[0] == '/')
return scm_make_shared_substring (filename, SCM_INUM0, SCM_MAKINUM (1)); return scm_substring (filename, SCM_INUM0, SCM_MAKINUM (1));
else else
return scm_dot_string; return scm_dot_string;
} }
else else
return scm_make_shared_substring (filename, return scm_substring (filename, SCM_MAKINUM (i + 1), SCM_MAKINUM (end + 1));
SCM_MAKINUM (i + 1),
SCM_MAKINUM (end + 1));
} }
#undef FUNC_NAME #undef FUNC_NAME

View file

@ -279,9 +279,9 @@ SCM_DEFINE (scm_open_file, "open-file", 2, 0, 0,
SCM_VALIDATE_ROSTRING (1,filename); SCM_VALIDATE_ROSTRING (1,filename);
SCM_VALIDATE_ROSTRING (2,modes); SCM_VALIDATE_ROSTRING (2,modes);
if (SCM_SUBSTRP (filename)) if (SCM_SUBSTRP (filename))
filename = scm_makfromstr (SCM_ROCHARS (filename), SCM_ROLENGTH (filename), 0); filename = scm_makfromstr (SCM_ROCHARS (filename), SCM_STRING_LENGTH (filename), 0);
if (SCM_SUBSTRP (modes)) if (SCM_SUBSTRP (modes))
modes = scm_makfromstr (SCM_ROCHARS (modes), SCM_ROLENGTH (modes), 0); modes = scm_makfromstr (SCM_ROCHARS (modes), SCM_STRING_LENGTH (modes), 0);
file = SCM_ROCHARS (filename); file = SCM_ROCHARS (filename);
mode = SCM_ROCHARS (modes); mode = SCM_ROCHARS (modes);

View file

@ -1639,7 +1639,7 @@ scm_gc_sweep ()
case scm_tc7_fvect: case scm_tc7_fvect:
case scm_tc7_dvect: case scm_tc7_dvect:
case scm_tc7_cvect: case scm_tc7_cvect:
m += SCM_HUGE_LENGTH (scmptr) * scm_uniform_element_size (scmptr); m += SCM_UVECTOR_LENGTH (scmptr) * scm_uniform_element_size (scmptr);
scm_must_free (SCM_UVECTOR_BASE (scmptr)); scm_must_free (SCM_UVECTOR_BASE (scmptr));
break; break;
#endif #endif

View file

@ -280,9 +280,6 @@ typedef unsigned long scm_c_bvec_limb_t;
#endif #endif
#define SCM_FREEP(x) (SCM_FREE_CELL_P (x))
#define SCM_NFREEP(x) (!SCM_FREEP (x))
#define SCM_MARKEDP SCM_GCMARKP #define SCM_MARKEDP SCM_GCMARKP
#define SCM_NMARKEDP(x) (!SCM_MARKEDP (x)) #define SCM_NMARKEDP(x) (!SCM_MARKEDP (x))
@ -371,6 +368,16 @@ extern int scm_init_storage (scm_sizet init_heap_size, int trig,
scm_sizet max_segment_size); scm_sizet max_segment_size);
extern void *scm_get_stack_base (void); extern void *scm_get_stack_base (void);
extern void scm_init_gc (void); extern void scm_init_gc (void);
#if (SCM_DEBUG_DEPRECATED == 0)
#define SCM_FREEP(x) (SCM_FREE_CELL_P (x))
#define SCM_NFREEP(x) (!SCM_FREE_CELL_P (x))
#endif /* SCM_DEBUG_DEPRECATED == 0 */
#endif /* GCH */ #endif /* GCH */
/* /*

View file

@ -121,7 +121,7 @@ scm_hasher(SCM obj, unsigned long n, scm_sizet d)
case scm_tc7_string: case scm_tc7_string:
return scm_string_hash (SCM_STRING_UCHARS (obj), SCM_STRING_LENGTH (obj)) % n; return scm_string_hash (SCM_STRING_UCHARS (obj), SCM_STRING_LENGTH (obj)) % n;
case scm_tc7_substring: case scm_tc7_substring:
return scm_string_hash (SCM_ROUCHARS (obj), SCM_ROLENGTH (obj)) % n; return scm_string_hash (SCM_ROUCHARS (obj), SCM_STRING_LENGTH (obj)) % n;
case scm_tc7_symbol: case scm_tc7_symbol:
return SCM_SYMBOL_HASH (obj) % n; return SCM_SYMBOL_HASH (obj) % n;
case scm_tc7_wvect: case scm_tc7_wvect:

View file

@ -266,7 +266,7 @@ SCM_DEFINE (scm_getpwuid, "getpw", 0, 1, 0,
{ {
SCM_VALIDATE_ROSTRING (1,user); SCM_VALIDATE_ROSTRING (1,user);
if (SCM_SUBSTRP (user)) if (SCM_SUBSTRP (user))
user = scm_makfromstr (SCM_ROCHARS (user), SCM_ROLENGTH (user), 0); user = scm_makfromstr (SCM_ROCHARS (user), SCM_STRING_LENGTH (user), 0);
entry = getpwnam (SCM_ROCHARS (user)); entry = getpwnam (SCM_ROCHARS (user));
} }
if (!entry) if (!entry)

View file

@ -477,7 +477,7 @@ taloop:
scm_sizet i; scm_sizet i;
scm_putc ('"', port); scm_putc ('"', port);
for (i = 0; i < SCM_ROLENGTH (exp); ++i) for (i = 0; i < SCM_STRING_LENGTH (exp); ++i)
switch (SCM_ROCHARS (exp)[i]) switch (SCM_ROCHARS (exp)[i])
{ {
case '"': case '"':
@ -490,7 +490,7 @@ taloop:
break; break;
} }
else else
scm_lfwrite (SCM_ROCHARS (exp), (scm_sizet) SCM_ROLENGTH (exp), scm_lfwrite (SCM_ROCHARS (exp), (scm_sizet) SCM_STRING_LENGTH (exp),
port); port);
break; break;
case scm_tc7_symbol: case scm_tc7_symbol:

View file

@ -146,7 +146,7 @@ scm_flush_ws (SCM port, const char *eoferr)
goteof: goteof:
if (eoferr) if (eoferr)
{ {
if (SCM_FILENAME (port) != SCM_BOOL_F) if (!SCM_FALSEP (SCM_FILENAME (port)))
scm_misc_error (eoferr, scm_misc_error (eoferr,
"end of file in ~A", "end of file in ~A",
SCM_LIST1 (SCM_FILENAME (port))); SCM_LIST1 (SCM_FILENAME (port)));

View file

@ -142,8 +142,6 @@ scm_make_root (SCM parent)
= root_state->def_errp = root_state->def_errp
= root_state->cur_loadp = root_state->cur_loadp
= root_state->fluids = root_state->fluids
= root_state->system_transformer
= root_state->top_level_lookup_closure_var
= root_state->handle = root_state->handle
= root_state->parent = root_state->parent
= SCM_BOOL_F; = SCM_BOOL_F;

View file

@ -115,9 +115,6 @@ typedef struct scm_root_state
SCM fluids; SCM fluids;
SCM system_transformer; /* No longer used (but kept for binary compatibility) */
SCM top_level_lookup_closure_var; /* No longer used (but kept for binary compatibility) */
SCM handle; /* The root object for this root state */ SCM handle; /* The root object for this root state */
SCM parent; /* The parent root object */ SCM parent; /* The parent root object */
} scm_root_state; } scm_root_state;

View file

@ -85,8 +85,8 @@ SCM_DEFINE (scm_system, "system", 0, 1, 0,
SCM_VALIDATE_ROSTRING (1,cmd); SCM_VALIDATE_ROSTRING (1,cmd);
SCM_DEFER_INTS; SCM_DEFER_INTS;
errno = 0; errno = 0;
if (SCM_ROSTRINGP (cmd)) if (SCM_SUBSTRP (cmd))
cmd = scm_makfromstr (SCM_ROCHARS (cmd), SCM_ROLENGTH (cmd), 0); cmd = scm_makfromstr (SCM_ROCHARS (cmd), SCM_STRING_LENGTH (cmd), 0);
rv = system(SCM_ROCHARS(cmd)); rv = system(SCM_ROCHARS(cmd));
if (rv == -1 || (rv == 127 && errno != 0)) if (rv == -1 || (rv == 127 && errno != 0))
SCM_SYSERROR; SCM_SYSERROR;

View file

@ -241,7 +241,7 @@ SCM_DEFINE (scm_string_length, "string-length", 1, 0, 0,
"Returns the number of characters in STRING") "Returns the number of characters in STRING")
#define FUNC_NAME s_scm_string_length #define FUNC_NAME s_scm_string_length
{ {
SCM_VALIDATE_STRINGORSUBSTR (1, string); SCM_VALIDATE_STRING (1, string);
return SCM_MAKINUM (SCM_STRING_LENGTH (string)); return SCM_MAKINUM (SCM_STRING_LENGTH (string));
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -254,9 +254,9 @@ SCM_DEFINE (scm_string_ref, "string-ref", 2, 0, 0,
{ {
int idx; int idx;
SCM_VALIDATE_STRINGORSUBSTR (1, str); SCM_VALIDATE_STRING (1, str);
SCM_VALIDATE_INUM_COPY (2, k, idx); SCM_VALIDATE_INUM_COPY (2, k, idx);
SCM_ASSERT_RANGE (2, k, idx >= 0 && idx < SCM_ROLENGTH (str)); SCM_ASSERT_RANGE (2, k, idx >= 0 && idx < SCM_STRING_LENGTH (str));
return SCM_MAKE_CHAR (SCM_ROUCHARS (str)[idx]); return SCM_MAKE_CHAR (SCM_ROUCHARS (str)[idx]);
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -288,14 +288,14 @@ SCM_DEFINE (scm_substring, "substring", 2, 1, 0,
long int from; long int from;
long int to; long int to;
SCM_VALIDATE_STRINGORSUBSTR (1, str); SCM_VALIDATE_STRING (1, str);
SCM_VALIDATE_INUM (2, start); SCM_VALIDATE_INUM (2, start);
SCM_VALIDATE_INUM_DEF (3, end, SCM_ROLENGTH (str)); SCM_VALIDATE_INUM_DEF (3, end, SCM_STRING_LENGTH (str));
from = SCM_INUM (start); from = SCM_INUM (start);
SCM_ASSERT_RANGE (2, start, 0 <= from && from <= SCM_ROLENGTH (str)); SCM_ASSERT_RANGE (2, start, 0 <= from && from <= SCM_STRING_LENGTH (str));
to = SCM_INUM (end); to = SCM_INUM (end);
SCM_ASSERT_RANGE (3, end, from <= to && to <= SCM_ROLENGTH (str)); SCM_ASSERT_RANGE (3, end, from <= to && to <= SCM_STRING_LENGTH (str));
return scm_makfromstr (&SCM_ROCHARS (str)[from], (scm_sizet) (to - from), 0); return scm_makfromstr (&SCM_ROCHARS (str)[from], (scm_sizet) (to - from), 0);
} }
@ -316,14 +316,14 @@ SCM_DEFINE (scm_string_append, "string-append", 0, 0, 1,
SCM_VALIDATE_REST_ARGUMENT (args); SCM_VALIDATE_REST_ARGUMENT (args);
for (l = args; !SCM_NULLP (l); l = SCM_CDR (l)) { for (l = args; !SCM_NULLP (l); l = SCM_CDR (l)) {
s = SCM_CAR (l); s = SCM_CAR (l);
SCM_VALIDATE_STRINGORSUBSTR (SCM_ARGn,s); SCM_VALIDATE_STRING (SCM_ARGn,s);
i += SCM_ROLENGTH (s); i += SCM_STRING_LENGTH (s);
} }
res = scm_makstr (i, 0); res = scm_makstr (i, 0);
data = SCM_STRING_UCHARS (res); data = SCM_STRING_UCHARS (res);
for (l = args;SCM_NIMP (l);l = SCM_CDR (l)) { for (l = args;SCM_NIMP (l);l = SCM_CDR (l)) {
s = SCM_CAR (l); s = SCM_CAR (l);
for (i = 0;i<SCM_ROLENGTH (s);i++) *data++ = SCM_ROUCHARS (s)[i]; for (i = 0;i<SCM_STRING_LENGTH (s);i++) *data++ = SCM_ROUCHARS (s)[i];
} }
return res; return res;
} }

View file

@ -342,8 +342,8 @@ SCM_DEFINE (scm_string_copy, "string-copy", 1, 0, 0,
"Returns a newly allocated copy of the given @var{string}. (r5rs)") "Returns a newly allocated copy of the given @var{string}. (r5rs)")
#define FUNC_NAME s_scm_string_copy #define FUNC_NAME s_scm_string_copy
{ {
SCM_VALIDATE_STRINGORSUBSTR (1,str); SCM_VALIDATE_STRING (1, str);
return scm_makfromstr (SCM_ROCHARS (str), (scm_sizet)SCM_ROLENGTH (str), 0); return scm_makfromstr (SCM_ROCHARS (str), SCM_STRING_LENGTH (str), 0);
} }
#undef FUNC_NAME #undef FUNC_NAME

View file

@ -81,13 +81,13 @@ SCM_DEFINE (scm_make_struct_layout, "make-struct-layout", 1, 0, 0,
#define FUNC_NAME s_scm_make_struct_layout #define FUNC_NAME s_scm_make_struct_layout
{ {
SCM new_sym; SCM new_sym;
SCM_VALIDATE_STRINGORSUBSTR (1, fields); SCM_VALIDATE_STRING (1, fields);
{ /* scope */ { /* scope */
char * field_desc; char * field_desc;
int len; int len;
int x; int x;
len = SCM_ROLENGTH (fields); len = SCM_STRING_LENGTH (fields);
field_desc = SCM_ROCHARS (fields); field_desc = SCM_ROCHARS (fields);
SCM_ASSERT (!(len & 1), fields, "odd length field specification", FUNC_NAME); SCM_ASSERT (!(len & 1), fields, "odd length field specification", FUNC_NAME);
@ -524,7 +524,7 @@ SCM_DEFINE (scm_make_vtable_vtable, "make-vtable-vtable", 2, 0, 1,
scm_bits_t * data; scm_bits_t * data;
SCM handle; SCM handle;
SCM_VALIDATE_STRINGORSUBSTR (1, user_fields); SCM_VALIDATE_STRING (1, user_fields);
SCM_VALIDATE_INUM (2, tail_array_size); SCM_VALIDATE_INUM (2, tail_array_size);
SCM_VALIDATE_REST_ARGUMENT (init); SCM_VALIDATE_REST_ARGUMENT (init);

View file

@ -833,8 +833,8 @@ SCM_DEFINE (scm_gensym, "gensym", 0, 1, 0,
} }
else else
{ {
SCM_VALIDATE_STRINGORSUBSTR (1, prefix); SCM_VALIDATE_STRING (1, prefix);
len = SCM_ROLENGTH (prefix); len = SCM_STRING_LENGTH (prefix);
if (len > MAX_PREFIX_LENGTH) if (len > MAX_PREFIX_LENGTH)
name = SCM_MUST_MALLOC (MAX_PREFIX_LENGTH + SCM_INTBUFLEN); name = SCM_MUST_MALLOC (MAX_PREFIX_LENGTH + SCM_INTBUFLEN);
strncpy (name, SCM_ROCHARS (prefix), len); strncpy (name, SCM_ROCHARS (prefix), len);
@ -871,8 +871,8 @@ SCM_DEFINE (scm_gentemp, "gentemp", 0, 2, 0,
} }
else else
{ {
SCM_VALIDATE_STRINGORSUBSTR (1, prefix); SCM_VALIDATE_STRING (1, prefix);
len = SCM_ROLENGTH (prefix); len = SCM_STRING_LENGTH (prefix);
if (len > MAX_PREFIX_LENGTH) if (len > MAX_PREFIX_LENGTH)
name = SCM_MUST_MALLOC (MAX_PREFIX_LENGTH + SCM_INTBUFLEN); name = SCM_MUST_MALLOC (MAX_PREFIX_LENGTH + SCM_INTBUFLEN);
strncpy (name, SCM_ROCHARS (prefix), len); strncpy (name, SCM_ROCHARS (prefix), len);

View file

@ -95,7 +95,7 @@ extern int scm_symhash_dim;
#define SCM_COERCE_SUBSTR(x) { if (SCM_SUBSTRP (x)) \ #define SCM_COERCE_SUBSTR(x) { if (SCM_SUBSTRP (x)) \
x = scm_makfromstr (SCM_ROCHARS (x), \ x = scm_makfromstr (SCM_ROCHARS (x), \
SCM_ROLENGTH (x), 0); } SCM_STRING_LENGTH (x), 0); }

View file

@ -316,6 +316,7 @@ typedef long scm_bits_t;
*/ */
#define SCM_ITAG7(x) (127 & SCM_UNPACK (x))
#define SCM_TYP7(x) (0x7f & SCM_CELL_TYPE (x)) #define SCM_TYP7(x) (0x7f & SCM_CELL_TYPE (x))
#define SCM_TYP7S(x) ((0x7f & ~2) & SCM_CELL_TYPE (x)) #define SCM_TYP7S(x) ((0x7f & ~2) & SCM_CELL_TYPE (x))

View file

@ -1,4 +1,4 @@
/* $Id: validate.h,v 1.17 2000-10-09 16:27:24 dirk Exp $ */ /* $Id: validate.h,v 1.18 2000-10-25 11:01:03 dirk Exp $ */
/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. /* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -144,12 +144,6 @@
#define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE (pos, str, STRINGP) #define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE (pos, str, STRINGP)
#define SCM_VALIDATE_STRINGORSUBSTR(pos, str) \
do { \
SCM_ASSERT (SCM_STRINGP (str) || SCM_SUBSTRP (str), \
str, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \ #define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \
do { \ do { \
SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \ SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \
@ -416,6 +410,14 @@
SCM_ASSERT (SCM_VECTORP (v) && len == SCM_VECTOR_LENGTH (v), v, pos, FUNC_NAME); \ SCM_ASSERT (SCM_VECTORP (v) && len == SCM_VECTOR_LENGTH (v), v, pos, FUNC_NAME); \
} while (0) } while (0)
#if (SCM_DEBUG_DEPRECATED == 0)
#define SCM_VALIDATE_STRINGORSUBSTR SCM_VALIDATE_STRING
#endif /* SCM_DEBUG_DEPRECATED == 0 */
#endif #endif
/* /*