"Returns #t iff OBJ is a string, else returns #f.")
#define FUNC_NAME s_scm_string_p
{
- return SCM_BOOL(SCM_STRINGP (obj));
+ return SCM_BOOL (SCM_STRINGP (obj));
}
#undef FUNC_NAME
+#if SCM_DEBUG_DEPRECATED == 0
+
+/* The concept of read-only strings will disappear in next release
+ * of Guile.
+ */
+
SCM_DEFINE (scm_read_only_string_p, "read-only-string?", 1, 0, 0,
(SCM x),
"Return true if OBJ can be read as a string,\n\n"
}
#undef FUNC_NAME
+#endif /* DEPRECATED */
+
SCM_REGISTER_PROC (s_scm_list_to_string, "list->string", 1, 0, 0, scm_string);
SCM_DEFINE (scm_string, "string", 0, 0, 1,
(SCM chrs),
+ "@deffnx primitive list->string chrs\n"
"Returns a newly allocated string composed of the arguments, CHRS.")
#define FUNC_NAME s_scm_string
{
#undef FUNC_NAME
SCM
-scm_makstr (long len, int slots)
+scm_makstr (long len, int dummy)
{
SCM s;
- scm_bits_t * mem;
+ char *mem = (char *) scm_must_malloc (len + 1, "scm_makstr");
+ mem[len] = 0;
SCM_NEWCELL (s);
- --slots;
- SCM_REDEFER_INTS;
- mem = (scm_bits_t *) scm_must_malloc (sizeof (scm_bits_t) * (slots + 1)
- + len + 1, "scm_makstr");
- if (slots >= 0)
- {
- int x;
- mem[slots] = (scm_bits_t) mem;
- for (x = 0; x < slots; ++x)
- mem[x] = SCM_UNPACK (SCM_BOOL_F);
- }
- SCM_SETCHARS (s, (char *) (mem + slots + 1));
+ SCM_SETCHARS (s, mem);
SCM_SETLENGTH (s, len, scm_tc7_string);
- SCM_REALLOW_INTS;
- SCM_CHARS (s)[len] = 0;
+
return s;
}
}
SCM
-scm_makfromstr (const char *src, scm_sizet len, int slots)
+scm_makfromstr (const char *src, scm_sizet len, int dummy)
{
- SCM s = scm_makstr (len, slots);
+ SCM s = scm_makstr (len, 0);
char *dst = SCM_CHARS (s);
while (len--)
"Returns the number of characters in STRING")
#define FUNC_NAME s_scm_string_length
{
- SCM_VALIDATE_ROSTRING (1,string);
- return SCM_MAKINUM (SCM_ROLENGTH (string));
+ SCM_VALIDATE_STRINGORSUBSTR (1, string);
+ return SCM_MAKINUM (SCM_LENGTH (string));
}
#undef FUNC_NAME
{
int idx;
- SCM_VALIDATE_ROSTRING (1, str);
+ SCM_VALIDATE_STRINGORSUBSTR (1, str);
SCM_VALIDATE_INUM_COPY (2, k, idx);
SCM_ASSERT_RANGE (2, k, idx >= 0 && idx < SCM_ROLENGTH (str));
return SCM_MAKE_CHAR (SCM_ROUCHARS (str)[idx]);
long int from;
long int to;
- SCM_VALIDATE_ROSTRING (1,str);
+ SCM_VALIDATE_STRINGORSUBSTR (1, str);
SCM_VALIDATE_INUM (2, start);
- SCM_VALIDATE_INUM_DEF (3,end,SCM_ROLENGTH(str));
+ SCM_VALIDATE_INUM_DEF (3, end, SCM_ROLENGTH (str));
from = SCM_INUM (start);
SCM_ASSERT_RANGE (2, start, 0 <= from && from <= SCM_ROLENGTH (str));
SCM_VALIDATE_REST_ARGUMENT (args);
for (l = args; !SCM_NULLP (l); l = SCM_CDR (l)) {
s = SCM_CAR (l);
- SCM_VALIDATE_ROSTRING (SCM_ARGn,s);
+ SCM_VALIDATE_STRINGORSUBSTR (SCM_ARGn,s);
i += SCM_ROLENGTH (s);
}
res = scm_makstr (i, 0);
}
#undef FUNC_NAME
+#if SCM_DEBUG_DEPRECATED == 0
+
+/* Explicit shared substrings will disappear from Guile.
+ *
+ * Instead, "normal" strings will be implemented using sharing
+ * internally, combined with a copy-on-write strategy.
+ */
+
SCM_DEFINE (scm_make_shared_substring, "make-shared-substring", 1, 2, 0,
(SCM str, SCM frm, SCM to),
"Return a shared substring of @var{str}. The semantics are the same as\n"
}
#undef FUNC_NAME
+#endif /* DEPRECATED */
+
void
scm_init_strings ()
{