SCM k;
SCM chr;
{
- SCM_ASSERT (SCM_NIMP (str) && SCM_STRINGP (str), str, SCM_ARG1, s_string_set_x);
+ SCM_ASSERT (SCM_NIMP (str) && SCM_STRINGP (str),
+ str, SCM_ARG1, s_string_set_x);
SCM_ASSERT (SCM_INUMP (k), k, SCM_ARG2, s_string_set_x);
SCM_ASSERT (SCM_ICHRP (chr), chr, SCM_ARG3, s_string_set_x);
- SCM_ASSERT (SCM_INUM (k) < SCM_LENGTH (str) && SCM_INUM (k) >= 0, k, SCM_OUTOFRANGE, s_string_set_x);
+ if (! SCM_RWSTRINGP (str))
+ scm_misc_error (s_string_set_x, "argument is a read-only string", str);
+ SCM_ASSERT (SCM_INUM (k) < SCM_LENGTH (str) && SCM_INUM (k) >= 0,
+ k, SCM_OUTOFRANGE, s_string_set_x);
SCM_UCHARS (str)[SCM_INUM (k)] = SCM_ICHR (chr);
return SCM_UNSPECIFIED;
}
#define SCM_STRINGP(x) (SCM_TYP7S(x)==scm_tc7_string)
#define SCM_NSTRINGP(x) (!SCM_STRINGP(x))
+/* Is X a writable string (i.e., not a substring)? */
+#define SCM_RWSTRINGP(x) (SCM_TYP7(x) == scm_tc7_string)
+#define SCM_NRWSTRINGP(x) (! SCM_RWSTRINGP (x))
+
\f