summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Herrmann <dirk@dirk-herrmanns-seiten.de>2001-03-22 12:52:03 +0000
committerDirk Herrmann <dirk@dirk-herrmanns-seiten.de>2001-03-22 12:52:03 +0000
commitbe54b15d85632c1da64f36cc68623b76efc7239e (patch)
treeff34697e889e8e37fc15922f2de70be0e5ce9395
parent3b9e23a7b6ab9d3628759c3fbaf625f10803e911 (diff)
downloadguile-be54b15d85632c1da64f36cc68623b76efc7239e.tar.gz
* Replace function scm_makstr with new function scm_allocate_string.
-rw-r--r--NEWS8
-rw-r--r--RELEASE1
-rw-r--r--libguile/ChangeLog13
-rw-r--r--libguile/gc.c2
-rw-r--r--libguile/gdbint.c4
-rw-r--r--libguile/numbers.c4
-rw-r--r--libguile/ports.c4
-rw-r--r--libguile/read.c6
-rw-r--r--libguile/strings.c33
-rw-r--r--libguile/strings.h3
-rw-r--r--libguile/strports.c6
-rw-r--r--libguile/unif.c2
12 files changed, 66 insertions, 20 deletions
diff --git a/NEWS b/NEWS
index 39b4fc05d..7569dbe08 100644
--- a/NEWS
+++ b/NEWS
@@ -520,6 +520,14 @@ These functions replace the function scm_remember.
Use one of the new functions scm_remember_upto_here_1,
scm_remember_upto_here_2 or scm_remember_upto_here instead.
+** New function: scm_allocate_string
+
+This function replaces the function scm_makstr.
+
+** Deprecated function: scm_makstr
+
+Use the new function scm_allocate_string instead.
+
** New global variable scm_gc_running_p introduced.
Use this variable to find out if garbage collection is being executed. Up to
diff --git a/RELEASE b/RELEASE
index d7bd44236..f4c521119 100644
--- a/RELEASE
+++ b/RELEASE
@@ -47,6 +47,7 @@ In release 1.6:
load.c: scm_read_and_eval_x
smob.c: scm_make_smob_type_mfpe, scm_set_smob_mfpe
gc.c: scm_remember
+ string.c: scm_makstr
- remove deprecated procedures:
boot-9.scm:eval-in-module
- remove deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL,
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 847dbc5b4..6ca3b0526 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,16 @@
+2001-03-22 Dirk Herrmann <D.Herrmann@tu-bs.de>
+
+ * gc.c (scm_init_storage), gdbint.c (scm_init_gdbint), numbers.c
+ (big2str), ports.c (scm_drain_input), read.c (scm_read,
+ scm_grow_tok_buf), strings.c (scm_string, scm_makfromstr,
+ scm_make_string, scm_string_append), strports.c (st_resize_port,
+ scm_object_to_string), unif.c (scm_make_uve): Replace calls to
+ scm_makstr with calls to scm_allocate_string.
+
+ * strings.[ch] (scm_allocate_string): New function.
+
+ * strings.[ch] (scm_makstr): Deprecated.
+
2001-03-18 Gary Houston <ghouston@arglist.com>
* posix.c (scm_tmpnam): check that return value from tmpnam is not
diff --git a/libguile/gc.c b/libguile/gc.c
index c99e3f0d4..ebcddca09 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -2630,7 +2630,7 @@ scm_init_storage ()
SCM_SETCDR (scm_undefineds, scm_undefineds);
scm_listofnull = scm_cons (SCM_EOL, SCM_EOL);
- scm_nullstr = scm_makstr (0L, 0);
+ scm_nullstr = scm_allocate_string (0);
scm_nullvect = scm_c_make_vector (0, SCM_UNDEFINED);
#define DEFAULT_SYMHASH_SIZE 277
diff --git a/libguile/gdbint.c b/libguile/gdbint.c
index e18fea8a8..8511365d3 100644
--- a/libguile/gdbint.c
+++ b/libguile/gdbint.c
@@ -1,5 +1,5 @@
/* GDB interface for Guile
- * Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation
+ * Copyright (C) 1996,1997,1999,2000,2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -329,7 +329,7 @@ scm_init_gdbint ()
s);
gdb_input_port = scm_permanent_object (port);
- tok_buf = scm_permanent_object (scm_makstr (30L, 0));
+ tok_buf = scm_permanent_object (scm_allocate_string (30));
}
/*
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 37dcb106e..17fa9fda1 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -2244,7 +2244,7 @@ big2str (SCM b, unsigned int radix)
scm_sizet k = 0;
scm_sizet radct = 0;
SCM_BIGDIG radpow = 1, radmod = 0;
- SCM ss = scm_makstr ((long) j, 0);
+ SCM ss = scm_allocate_string (j);
char *s = SCM_STRING_CHARS (ss), c;
while ((long) radpow * radix < SCM_BIGRAD)
{
diff --git a/libguile/ports.c b/libguile/ports.c
index 04725b87e..6884811d1 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -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 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -322,7 +322,7 @@ SCM_DEFINE (scm_drain_input, "drain-input", 1, 0, 0,
if (pt->read_buf == pt->putback_buf)
count += pt->saved_read_end - pt->saved_read_pos;
- result = scm_makstr (count, 0);
+ result = scm_allocate_string (count);
scm_take_from_input_buffers (port, SCM_STRING_CHARS (result), count);
return result;
diff --git a/libguile/read.c b/libguile/read.c
index 578e35330..221035ff1 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1999,2000,2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -116,7 +116,7 @@ SCM_DEFINE (scm_read, "read", 0, 1, 0,
return SCM_EOF_VAL;
scm_ungetc (c, port);
- tok_buf = scm_makstr (30L, 0);
+ tok_buf = scm_allocate_string (30);
return scm_lreadr (&tok_buf, port, &copy);
}
#undef FUNC_NAME
@@ -127,7 +127,7 @@ char *
scm_grow_tok_buf (SCM *tok_buf)
{
unsigned long int oldlen = SCM_STRING_LENGTH (*tok_buf);
- SCM newstr = scm_makstr (2 * oldlen, 0);
+ SCM newstr = scm_allocate_string (2 * oldlen);
unsigned long int i;
for (i = 0; i != oldlen; ++i)
diff --git a/libguile/strings.c b/libguile/strings.c
index e2277fe39..cf8ddca28 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1998,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,2000,2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -106,7 +106,7 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1,
long i = scm_ilength (chrs);
SCM_ASSERT (i >= 0, chrs, SCM_ARGn, FUNC_NAME);
- result = scm_makstr (i, 0);
+ result = scm_allocate_string (i);
}
{
@@ -125,6 +125,7 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1,
}
#undef FUNC_NAME
+#if (SCM_DEBUG_DEPRECATED == 0)
SCM
scm_makstr (long len, int dummy)
@@ -146,6 +147,7 @@ scm_makstr (long len, int dummy)
}
#undef FUNC_NAME
+#endif /* SCM_DEBUG_DEPRECATED == 0 */
/* converts C scm_array of strings to SCM scm_list of strings. */
/* If argc < 0, a null terminated scm_array is assumed. */
@@ -199,7 +201,7 @@ scm_take0str (char *s)
SCM
scm_makfromstr (const char *src, scm_sizet len, int dummy)
{
- SCM s = scm_makstr (len, 0);
+ SCM s = scm_allocate_string (len);
char *dst = SCM_STRING_CHARS (s);
while (len--)
@@ -222,6 +224,27 @@ scm_makfrom0str_opt (const char *src)
}
+SCM
+scm_allocate_string (scm_sizet len)
+#define FUNC_NAME "scm_allocate_string"
+{
+ char *mem;
+ SCM s;
+
+ SCM_ASSERT_RANGE (1, scm_long2num (len), len <= SCM_STRING_MAX_LENGTH);
+
+ mem = (char *) scm_must_malloc (len + 1, FUNC_NAME);
+ mem[len] = 0;
+
+ SCM_NEWCELL (s);
+ SCM_SET_STRING_CHARS (s, mem);
+ SCM_SET_STRING_LENGTH (s, len);
+
+ return s;
+}
+#undef FUNC_NAME
+
+
SCM_DEFINE (scm_make_string, "make-string", 1, 1, 0,
(SCM k, SCM chr),
"Return a newly allocated string of\n"
@@ -237,7 +260,7 @@ SCM_DEFINE (scm_make_string, "make-string", 1, 1, 0,
SCM_ASSERT_RANGE (1, k, i >= 0);
- res = scm_makstr (i, 0);
+ res = scm_allocate_string (i);
if (!SCM_UNBNDP (chr))
{
unsigned char *dst;
@@ -348,7 +371,7 @@ SCM_DEFINE (scm_string_append, "string-append", 0, 0, 1,
SCM_VALIDATE_STRING (SCM_ARGn,s);
i += SCM_STRING_LENGTH (s);
}
- res = scm_makstr (i, 0);
+ res = scm_allocate_string (i);
data = SCM_STRING_UCHARS (res);
for (l = args;SCM_NIMP (l);l = SCM_CDR (l)) {
s = SCM_CAR (l);
diff --git a/libguile/strings.h b/libguile/strings.h
index cc3b54669..76919d7c5 100644
--- a/libguile/strings.h
+++ b/libguile/strings.h
@@ -70,13 +70,13 @@
extern SCM scm_string_p (SCM x);
extern SCM scm_read_only_string_p (SCM x);
extern SCM scm_string (SCM chrs);
-extern SCM scm_makstr (long len, int);
extern SCM scm_makfromstrs (int argc, char **argv);
extern SCM scm_take_str (char *s, int len);
extern SCM scm_take0str (char *s);
extern SCM scm_makfromstr (const char *src, scm_sizet len, int);
extern SCM scm_makfrom0str (const char *src);
extern SCM scm_makfrom0str_opt (const char *src);
+extern SCM scm_allocate_string (scm_sizet len);
extern SCM scm_make_string (SCM k, SCM chr);
extern SCM scm_string_length (SCM str);
extern SCM scm_string_ref (SCM str, SCM k);
@@ -102,6 +102,7 @@ extern void scm_init_strings (void);
? (char *) SCM_CELL_WORD_1 (SCM_CDDR (x)) + SCM_INUM (SCM_CADR (x)) \
: (char *) SCM_CELL_WORD_1 (x))
extern SCM scm_make_shared_substring (SCM str, SCM frm, SCM to);
+extern SCM scm_makstr (long len, int);
#endif /* SCM_DEBUG_DEPRECATED == 0 */
diff --git a/libguile/strports.c b/libguile/strports.c
index 299337d97..c1a20e60b 100644
--- a/libguile/strports.c
+++ b/libguile/strports.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1998,1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,1999,2000,2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -100,7 +100,7 @@ static void
st_resize_port (scm_port *pt, off_t new_size)
{
SCM old_stream = SCM_PACK (pt->stream);
- SCM new_stream = scm_makstr (new_size, 0);
+ SCM new_stream = scm_allocate_string (new_size);
unsigned long int old_size = SCM_STRING_LENGTH (old_stream);
unsigned long int min_size = min (old_size, new_size);
unsigned long int i;
@@ -323,7 +323,7 @@ SCM_DEFINE (scm_object_to_string, "object->string", 1, 1, 0,
if (!SCM_UNBNDP (printer))
SCM_VALIDATE_PROC (2, printer);
- str = scm_makstr (0, 0);
+ str = scm_allocate_string (0);
port = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_WRTNG, FUNC_NAME);
if (SCM_UNBNDP (printer))
diff --git a/libguile/unif.c b/libguile/unif.c
index eb2fcb409..9255abb37 100644
--- a/libguile/unif.c
+++ b/libguile/unif.c
@@ -186,7 +186,7 @@ scm_make_uve (long k, SCM prot)
else if (SCM_CHARP (prot))
{
i = sizeof (char) * k;
- return scm_makstr (i, 0);
+ return scm_allocate_string (i);
}
else if (SCM_INUMP (prot))
{