mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
(gh_set_substr): Made src const.
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length, scm_i_string_writable_chars, scm_i_string_stop_writing): New, to replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all uses. (scm_i_make_string, scm_c_make_string): New, to replace scm_allocate_string. Updated all uses. (SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS, SCM_STRING_LENGTH): Deprecated. (scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string, scm_str2string, scm_makfrom0str, scm_makfrom0str_opt): Discouraged. Replaced all uses with scm_from_locale_string or similar, as appropriate. (scm_c_string_length, scm_c_string_ref, scm_c_string_set_x, scm_c_substring, scm_c_substring_shared, scm_c_substring_copy, scm_substring_shared, scm_substring_copy): New. * symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC, SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS, SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol, scm_str2symbol, scm_mem2uninterned_symbol): Discouraged. (SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str): Deprecated. (SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS, SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed. (scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln): New, to replace scm_str2symbol and scm_mem2symbol, respectively. Updated all uses. (scm_gensym): Generate only the number suffix in the buffer, just string-append the prefix.
This commit is contained in:
parent
272632a67c
commit
f76c6bb234
2 changed files with 19 additions and 39 deletions
|
@ -81,7 +81,7 @@ SCM_API SCM gh_double2scm(double x);
|
|||
SCM_API SCM gh_char2scm(char c);
|
||||
SCM_API SCM gh_str2scm(const char *s, size_t len);
|
||||
SCM_API SCM gh_str02scm(const char *s);
|
||||
SCM_API void gh_set_substr(char *src, SCM dst, long start, size_t len);
|
||||
SCM_API void gh_set_substr(const char *src, SCM dst, long start, size_t len);
|
||||
SCM_API SCM gh_symbol2scm(const char *symbol_str);
|
||||
SCM_API SCM gh_ints2scm(const int *d, long n);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2004 Free Software Foundation, Inc.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
|
@ -61,12 +61,12 @@ gh_char2scm (char c)
|
|||
SCM
|
||||
gh_str2scm (const char *s, size_t len)
|
||||
{
|
||||
return scm_mem2string (s, len);
|
||||
return scm_from_locale_stringn (s, len);
|
||||
}
|
||||
SCM
|
||||
gh_str02scm (const char *s)
|
||||
{
|
||||
return scm_makfrom0str (s);
|
||||
return scm_from_locale_string (s);
|
||||
}
|
||||
/* Copy LEN characters at SRC into the *existing* Scheme string DST,
|
||||
starting at START. START is an index into DST; zero means the
|
||||
|
@ -75,18 +75,19 @@ gh_str02scm (const char *s)
|
|||
If START + LEN is off the end of DST, signal an out-of-range
|
||||
error. */
|
||||
void
|
||||
gh_set_substr (char *src, SCM dst, long start, size_t len)
|
||||
gh_set_substr (const char *src, SCM dst, long start, size_t len)
|
||||
{
|
||||
char *dst_ptr;
|
||||
size_t dst_len;
|
||||
|
||||
SCM_ASSERT (SCM_I_STRINGP (dst), dst, SCM_ARG3, "gh_set_substr");
|
||||
SCM_ASSERT (scm_is_string (dst), dst, SCM_ARG3, "gh_set_substr");
|
||||
|
||||
dst_ptr = SCM_I_STRING_CHARS (dst);
|
||||
dst_len = SCM_I_STRING_LENGTH (dst);
|
||||
dst_len = scm_i_string_length (dst);
|
||||
SCM_ASSERT (start + len <= dst_len, dst, SCM_ARG4, "gh_set_substr");
|
||||
|
||||
|
||||
dst_ptr = scm_i_string_writable_chars (dst);
|
||||
memmove (dst_ptr + start, src, len);
|
||||
scm_i_string_stop_writing ();
|
||||
scm_remember_upto_here_1 (dst);
|
||||
}
|
||||
|
||||
|
@ -94,7 +95,7 @@ gh_set_substr (char *src, SCM dst, long start, size_t len)
|
|||
SCM
|
||||
gh_symbol2scm (const char *symbol_str)
|
||||
{
|
||||
return scm_str2symbol(symbol_str);
|
||||
return scm_from_locale_symbol(symbol_str);
|
||||
}
|
||||
|
||||
SCM
|
||||
|
@ -259,12 +260,12 @@ gh_scm2chars (SCM obj, char *m)
|
|||
break;
|
||||
#endif
|
||||
case scm_tc7_string:
|
||||
n = SCM_I_STRING_LENGTH (obj);
|
||||
n = scm_i_string_length (obj);
|
||||
if (m == 0)
|
||||
m = (char *) malloc (n * sizeof (char));
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
memcpy (m, SCM_I_STRING_CHARS (obj), n * sizeof (char));
|
||||
memcpy (m, scm_i_string_chars (obj), n * sizeof (char));
|
||||
break;
|
||||
default:
|
||||
scm_wrong_type_arg (0, 0, obj);
|
||||
|
@ -525,7 +526,7 @@ gh_scm2newstr (SCM str, size_t *lenp)
|
|||
|
||||
ret_str = scm_to_locale_string (str);
|
||||
if (lenp)
|
||||
*lenp = SCM_I_STRING_LENGTH (str);
|
||||
*lenp = scm_i_string_length (str);
|
||||
return ret_str;
|
||||
}
|
||||
|
||||
|
@ -540,11 +541,11 @@ void
|
|||
gh_get_substr (SCM src, char *dst, long start, size_t len)
|
||||
{
|
||||
size_t src_len, effective_length;
|
||||
SCM_ASSERT (SCM_I_STRINGP (src), src, SCM_ARG3, "gh_get_substr");
|
||||
SCM_ASSERT (scm_is_string (src), src, SCM_ARG3, "gh_get_substr");
|
||||
|
||||
src_len = SCM_I_STRING_LENGTH (src);
|
||||
src_len = scm_i_string_length (src);
|
||||
effective_length = (len < src_len) ? len : src_len;
|
||||
memcpy (dst + start, SCM_I_STRING_CHARS (src), effective_length * sizeof (char));
|
||||
memcpy (dst + start, scm_i_string_chars (src), effective_length * sizeof (char));
|
||||
/* FIXME: must signal an error if len > src_len */
|
||||
scm_remember_upto_here_1 (src);
|
||||
}
|
||||
|
@ -561,28 +562,7 @@ gh_get_substr (SCM src, char *dst, long start, size_t len)
|
|||
char *
|
||||
gh_symbol2newstr (SCM sym, size_t *lenp)
|
||||
{
|
||||
char *ret_str;
|
||||
size_t len;
|
||||
|
||||
SCM_ASSERT (SCM_SYMBOLP (sym), sym, SCM_ARG3, "gh_scm2newsymbol");
|
||||
|
||||
len = SCM_SYMBOL_LENGTH (sym);
|
||||
|
||||
ret_str = (char *) malloc ((len + 1) * sizeof (char));
|
||||
if (ret_str == NULL)
|
||||
return NULL;
|
||||
/* so we copy sym to ret_str, which is what we will allocate */
|
||||
memcpy (ret_str, SCM_SYMBOL_CHARS (sym), len);
|
||||
scm_remember_upto_here_1 (sym);
|
||||
/* now make sure we null-terminate it */
|
||||
ret_str[len] = '\0';
|
||||
|
||||
if (lenp != NULL)
|
||||
{
|
||||
*lenp = len;
|
||||
}
|
||||
|
||||
return ret_str;
|
||||
return gh_scm2newstr (scm_symbol_to_string (sym), lenp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -665,7 +645,7 @@ gh_module_lookup (SCM module, const char *sname)
|
|||
|
||||
SCM_VALIDATE_MODULE (SCM_ARG1, module);
|
||||
|
||||
sym = scm_str2symbol (sname);
|
||||
sym = scm_from_locale_symbol (sname);
|
||||
var = scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F);
|
||||
if (var != SCM_BOOL_F)
|
||||
return SCM_VARIABLE_REF (var);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue