* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
-/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
- gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
\f
#include "libguile/_scm.h"
#include "libguile/chars.h"
-
+#include "libguile/root.h"
#include "libguile/strings.h"
+#include "libguile/deprecation.h"
#include "libguile/validate.h"
+
\f
/* {Strings}
{
unsigned char *data = SCM_STRING_UCHARS (result);
- while (SCM_NNULLP (chrs))
+ while (!SCM_NULLP (chrs))
{
SCM elt = SCM_CAR (chrs);
#if (SCM_DEBUG_DEPRECATED == 0)
SCM
-scm_makstr (long len, int dummy)
+scm_makstr (size_t len, int dummy)
#define FUNC_NAME "scm_makstr"
{
SCM s;
if (0 > i)
for (i = 0; argv[i]; i++);
while (i--)
- lst = scm_cons (scm_makfromstr (argv[i], (scm_sizet) strlen (argv[i]), 0), lst);
+ lst = scm_cons (scm_mem2string (argv[i], strlen (argv[i])), lst);
return lst;
}
strings by claiming they're shared substrings of a string we just
made up. */
SCM
-scm_take_str (char *s, int len)
+scm_take_str (char *s, size_t len)
#define FUNC_NAME "scm_take_str"
{
SCM answer;
return scm_take_str (s, strlen (s));
}
+#if (SCM_DEBUG_DEPRECATED == 0)
+
+SCM
+scm_makfromstr (const char *src, size_t len, int dummy SCM_UNUSED)
+{
+ scm_c_issue_deprecation_warning ("`scm_makfromstr' is deprecated. "
+ "Use `scm_mem2string' instead.");
+
+ return scm_mem2string (src, len);
+}
+
+#endif
+
SCM
-scm_makfromstr (const char *src, scm_sizet len, int dummy)
+scm_mem2string (const char *src, size_t len)
{
SCM s = scm_allocate_string (len);
char *dst = SCM_STRING_CHARS (s);
scm_makfrom0str (const char *src)
{
if (!src) return SCM_BOOL_F;
- return scm_makfromstr (src, (scm_sizet) strlen (src), 0);
+ return scm_mem2string (src, strlen (src));
}
SCM
-scm_allocate_string (scm_sizet len)
+scm_allocate_string (size_t len)
#define FUNC_NAME "scm_allocate_string"
{
char *mem;
"indexing. @var{k} must be a valid index of @var{str}.")
#define FUNC_NAME s_scm_string_ref
{
- int idx;
+ long idx;
SCM_VALIDATE_STRING (1, str);
SCM_VALIDATE_INUM_COPY (2, k, idx);
{
long int from;
long int to;
+ SCM substr;
SCM_VALIDATE_STRING (1, str);
SCM_VALIDATE_INUM (2, start);
to = SCM_INUM (end);
SCM_ASSERT_RANGE (3, end, from <= to && to <= SCM_STRING_LENGTH (str));
- return scm_makfromstr (&SCM_STRING_CHARS (str)[from], (scm_sizet) (to - from), 0);
+ substr = scm_mem2string (&SCM_STRING_CHARS (str)[from], to - from);
+ scm_remember_upto_here_1 (str);
+ return substr;
}
#undef FUNC_NAME
#define FUNC_NAME s_scm_string_append
{
SCM res;
- register long i = 0;
+ size_t i = 0;
register SCM l, s;
register unsigned char *data;
}
res = scm_allocate_string (i);
data = SCM_STRING_UCHARS (res);
- for (l = args;SCM_NIMP (l);l = SCM_CDR (l)) {
+ for (l = args; !SCM_NULLP (l);l = SCM_CDR (l)) {
s = SCM_CAR (l);
for (i = 0;i<SCM_STRING_LENGTH (s);i++) *data++ = SCM_STRING_UCHARS (s)[i];
}
SCM_DEFINE (scm_make_shared_substring, "make-shared-substring", 1, 2, 0,
(SCM str, SCM start, SCM end),
- "Return a shared substring of @var{str}. The semantics are the\n"
+ "Return a shared substring of @var{str}. The arguments are the\n"
"same as for the @code{substring} function: the shared substring\n"
"returned includes all of the text from @var{str} between\n"
"indexes @var{start} (inclusive) and @var{end} (exclusive). If\n"
void
scm_init_strings ()
{
+ scm_nullstr = scm_allocate_string (0);
+
#ifndef SCM_MAGIC_SNARFER
#include "libguile/strings.x"
#endif