mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
* strings.h, deprecated.h (SCM_STRING_COERCE_0TERMINATION_X):
Moved from string.h to deprecated.h. * deprecated.c, deprecated.h (SCM_CHARS, SCM_LENGTH): Removed. * strings.h, strings.c (SCM_MAKE_STRING_TAG): Rename dto SCM_I_MAKE_STRING_TAG, changed all uses. (SCM_STRING_CHARS, SCM_STRING_UCHARS, SCM_STRING_LENGTH): Renamed to SCM_I_STRING_CHARS, SCM_I_STRING_UCHARS, and SCM_I_LENGTH respectively. For a short time, the old names are still there as aliases. Not all uses have been changed yet, but the ones in strings.c have. (SCM_STRING_MAX_LEN): Do not hardcode to 24 bits, compute from SCM_T_BITS_MAX. (scm_is_string, scm_from_locale_string, scm_from_locale_stringn, scm_take_locale_string, scm_take_locale_stringn, scm_to_locale_string, scm_to_locale_stringn, scm_to_locale_stringbuf): New. (scm_c_string2str, scm_c_substring2str): Deprecated by moving to deprecated.[hc]. Implemented in terms of the new functions above. (scm_take_str, scm_take0str, scm_mem2string, scm_str2string, scm_makfrom0str): Reimplemented in terms of the new functions from above. They will be discouraged shortly. (scm_substring): Do not use scm_mem2string. (scm_i_allocate_string_pointers, scm_i_free_string_pointers): New, to replace similar code from posix.c, simpos.c, and dynl.c. (scm_string_append): Use memcpy instead of explicit loop. Do not use register keyword. Use plain 'char' instead of 'unsigned char'.
This commit is contained in:
parent
8d3fd10b91
commit
c829a4274f
4 changed files with 278 additions and 148 deletions
|
@ -649,33 +649,6 @@ scm_strprint_obj (SCM obj)
|
|||
return scm_object_to_string (obj, SCM_UNDEFINED);
|
||||
}
|
||||
|
||||
char *
|
||||
scm_i_object_chars (SCM obj)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("SCM_CHARS is deprecated. Use SCM_STRING_CHARS or "
|
||||
"SCM_SYMBOL_CHARS instead.");
|
||||
if (SCM_STRINGP (obj))
|
||||
return SCM_STRING_CHARS (obj);
|
||||
if (SCM_SYMBOLP (obj))
|
||||
return SCM_SYMBOL_CHARS (obj);
|
||||
abort ();
|
||||
}
|
||||
|
||||
long
|
||||
scm_i_object_length (SCM obj)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("SCM_LENGTH is deprecated. Use SCM_STRING_LENGTH instead, for example.");
|
||||
if (SCM_STRINGP (obj))
|
||||
return SCM_STRING_LENGTH (obj);
|
||||
if (SCM_SYMBOLP (obj))
|
||||
return SCM_SYMBOL_LENGTH (obj);
|
||||
if (SCM_VECTORP (obj))
|
||||
return SCM_VECTOR_LENGTH (obj);
|
||||
abort ();
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_sym2ovcell_soft (SCM sym, SCM obarray)
|
||||
{
|
||||
|
@ -841,8 +814,8 @@ SCM_DEFINE (scm_string_to_obarray_symbol, "string->obarray-symbol", 2, 1, 0,
|
|||
else if (scm_is_eq (o, SCM_BOOL_T))
|
||||
o = SCM_BOOL_F;
|
||||
|
||||
vcell = scm_intern_obarray_soft (SCM_STRING_CHARS(s),
|
||||
SCM_STRING_LENGTH (s),
|
||||
vcell = scm_intern_obarray_soft (SCM_I_STRING_CHARS(s),
|
||||
SCM_I_STRING_LENGTH (s),
|
||||
o,
|
||||
softness);
|
||||
if (scm_is_false (vcell))
|
||||
|
@ -1074,10 +1047,10 @@ SCM_DEFINE (scm_gentemp, "gentemp", 0, 2, 0,
|
|||
else
|
||||
{
|
||||
SCM_VALIDATE_STRING (1, prefix);
|
||||
len = SCM_STRING_LENGTH (prefix);
|
||||
len = SCM_I_STRING_LENGTH (prefix);
|
||||
if (len > MAX_PREFIX_LENGTH)
|
||||
name = SCM_MUST_MALLOC (MAX_PREFIX_LENGTH + SCM_INTBUFLEN);
|
||||
strncpy (name, SCM_STRING_CHARS (prefix), len);
|
||||
strncpy (name, SCM_I_STRING_CHARS (prefix), len);
|
||||
}
|
||||
|
||||
if (SCM_UNBNDP (obarray))
|
||||
|
@ -1129,6 +1102,44 @@ SCM_INUM (SCM obj)
|
|||
return scm_to_intmax (obj);
|
||||
}
|
||||
|
||||
char *
|
||||
scm_c_string2str (SCM obj, char *str, size_t *lenp)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("scm_c_string2str is deprecated. Use scm_to_locale_stringbuf or similar instead.");
|
||||
|
||||
if (str == NULL)
|
||||
{
|
||||
char *result = scm_to_locale_string (obj);
|
||||
if (lenp)
|
||||
*lenp = SCM_I_STRING_LENGTH (obj);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Pray that STR is large enough.
|
||||
*/
|
||||
size_t len = scm_to_locale_stringbuf (obj, str, SCM_I_SIZE_MAX);
|
||||
str[len] = '\0';
|
||||
if (lenp)
|
||||
*lenp = len;
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
scm_c_substring2str (SCM obj, char *str, size_t start, size_t len)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("scm_c_substring2str is deprecated. Use scm_substring plus scm_to_locale_stringbuf instead.");
|
||||
|
||||
if (start)
|
||||
obj = scm_substring (obj, scm_from_size_t (start), SCM_UNDEFINED);
|
||||
|
||||
scm_to_locale_stringbuf (obj, str, len);
|
||||
return str;
|
||||
}
|
||||
|
||||
double
|
||||
scm_truncate (double x)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue