mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
* strings.h, strings.c (scm_i_get_substring_spec): New.
* socket.c, rw.c, deprecated.h, validate.h (SCM_VALIDATE_STRING_COPY): Deprecated. Replaced all uses with SCM_VALIDATE_STRING plus SCM_I_STRING_CHARS or scm_to_locale_string, etc. (SCM_VALIDATE_SUBSTRING_SPEC_COPY): Deprecated. Replaced as above, plus scm_i_get_substring_spec.
This commit is contained in:
parent
396e5506d6
commit
6f14f578d2
4 changed files with 50 additions and 25 deletions
|
@ -410,6 +410,35 @@ SCM_API char *scm_c_substring2str (SCM obj, char *str, size_t start, size_t len)
|
||||||
SCM_API double scm_truncate (double x);
|
SCM_API double scm_truncate (double x);
|
||||||
SCM_API double scm_round (double x);
|
SCM_API double scm_round (double x);
|
||||||
|
|
||||||
|
/* Deprecated because we don't want people to access the internal
|
||||||
|
representation of strings directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \
|
||||||
|
do { \
|
||||||
|
SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \
|
||||||
|
cvar = SCM_STRING_CHARS(str); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/* validate a string and optional start/end arguments which default to
|
||||||
|
0/string-len. this is unrelated to the old shared substring
|
||||||
|
support, so please do not deprecate it :) */
|
||||||
|
#define SCM_VALIDATE_SUBSTRING_SPEC_COPY(pos_str, str, c_str, \
|
||||||
|
pos_start, start, c_start,\
|
||||||
|
pos_end, end, c_end) \
|
||||||
|
do {\
|
||||||
|
SCM_VALIDATE_STRING_COPY (pos_str, str, c_str);\
|
||||||
|
c_start = SCM_UNBNDP(start)? 0 : scm_to_size_t (start);\
|
||||||
|
c_end = SCM_UNBNDP(end)? SCM_STRING_LENGTH(str) : scm_to_size_t (end);\
|
||||||
|
SCM_ASSERT_RANGE (pos_start, start,\
|
||||||
|
0 <= c_start \
|
||||||
|
&& (size_t) c_start <= SCM_STRING_LENGTH (str));\
|
||||||
|
SCM_ASSERT_RANGE (pos_end, end,\
|
||||||
|
c_start <= c_end \
|
||||||
|
&& (size_t) c_end <= SCM_STRING_LENGTH (str));\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
void scm_i_init_deprecated (void);
|
void scm_i_init_deprecated (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -452,6 +452,22 @@ scm_i_free_string_pointers (char **pointers)
|
||||||
free (pointers);
|
free (pointers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
scm_i_get_substring_spec (size_t len,
|
||||||
|
SCM start, size_t *cstart,
|
||||||
|
SCM end, size_t *cend)
|
||||||
|
{
|
||||||
|
if (SCM_UNBNDP (start))
|
||||||
|
*cstart = 0;
|
||||||
|
else
|
||||||
|
*cstart = scm_to_unsigned_integer (start, 0, len);
|
||||||
|
|
||||||
|
if (SCM_UNBNDP (end))
|
||||||
|
*cend = len;
|
||||||
|
else
|
||||||
|
*cend = scm_to_unsigned_integer (end, *cstart, len);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
scm_init_strings ()
|
scm_init_strings ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,6 +72,9 @@ SCM_API size_t scm_to_locale_stringbuf (SCM str, char *buf, size_t max_len);
|
||||||
|
|
||||||
SCM_API char **scm_i_allocate_string_pointers (SCM list);
|
SCM_API char **scm_i_allocate_string_pointers (SCM list);
|
||||||
SCM_API void scm_i_free_string_pointers (char **pointers);
|
SCM_API void scm_i_free_string_pointers (char **pointers);
|
||||||
|
SCM_API void scm_i_get_substring_spec (size_t len,
|
||||||
|
SCM start, size_t *cstart,
|
||||||
|
SCM end, size_t *cend);
|
||||||
|
|
||||||
SCM_API void scm_init_strings (void);
|
SCM_API void scm_init_strings (void);
|
||||||
|
|
||||||
|
|
|
@ -152,31 +152,7 @@
|
||||||
cvar = SCM_CHAR (scm); \
|
cvar = SCM_CHAR (scm); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE_MSG (pos, str, STRINGP, "string")
|
#define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE_MSG (pos, str, I_STRINGP, "string")
|
||||||
|
|
||||||
#define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \
|
|
||||||
do { \
|
|
||||||
SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \
|
|
||||||
cvar = SCM_STRING_CHARS(str); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* validate a string and optional start/end arguments which default to
|
|
||||||
0/string-len. this is unrelated to the old shared substring
|
|
||||||
support, so please do not deprecate it :) */
|
|
||||||
#define SCM_VALIDATE_SUBSTRING_SPEC_COPY(pos_str, str, c_str, \
|
|
||||||
pos_start, start, c_start,\
|
|
||||||
pos_end, end, c_end) \
|
|
||||||
do {\
|
|
||||||
SCM_VALIDATE_STRING_COPY (pos_str, str, c_str);\
|
|
||||||
c_start = SCM_UNBNDP(start)? 0 : scm_to_size_t (start);\
|
|
||||||
c_end = SCM_UNBNDP(end)? SCM_STRING_LENGTH(str) : scm_to_size_t (end);\
|
|
||||||
SCM_ASSERT_RANGE (pos_start, start,\
|
|
||||||
0 <= c_start \
|
|
||||||
&& (size_t) c_start <= SCM_STRING_LENGTH (str));\
|
|
||||||
SCM_ASSERT_RANGE (pos_end, end,\
|
|
||||||
c_start <= c_end \
|
|
||||||
&& (size_t) c_end <= SCM_STRING_LENGTH (str));\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define SCM_VALIDATE_REAL(pos, z) SCM_MAKE_VALIDATE_MSG (pos, z, REALP, "real")
|
#define SCM_VALIDATE_REAL(pos, z) SCM_MAKE_VALIDATE_MSG (pos, z, REALP, "real")
|
||||||
|
|
||||||
|
@ -386,6 +362,7 @@
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
#endif /* SCM_VALIDATE_H */
|
#endif /* SCM_VALIDATE_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue