1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 14:21:10 +02:00

* Replace function scm_makstr with new function scm_allocate_string.

This commit is contained in:
Dirk Herrmann 2001-03-22 12:52:03 +00:00
parent 3b9e23a7b6
commit be54b15d85
12 changed files with 66 additions and 20 deletions

8
NEWS
View file

@ -520,6 +520,14 @@ These functions replace the function scm_remember.
Use one of the new functions scm_remember_upto_here_1, Use one of the new functions scm_remember_upto_here_1,
scm_remember_upto_here_2 or scm_remember_upto_here instead. 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. ** New global variable scm_gc_running_p introduced.
Use this variable to find out if garbage collection is being executed. Up to Use this variable to find out if garbage collection is being executed. Up to

View file

@ -47,6 +47,7 @@ In release 1.6:
load.c: scm_read_and_eval_x load.c: scm_read_and_eval_x
smob.c: scm_make_smob_type_mfpe, scm_set_smob_mfpe smob.c: scm_make_smob_type_mfpe, scm_set_smob_mfpe
gc.c: scm_remember gc.c: scm_remember
string.c: scm_makstr
- remove deprecated procedures: - remove deprecated procedures:
boot-9.scm:eval-in-module boot-9.scm:eval-in-module
- remove deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL, - remove deprecated macros: SCM_OUTOFRANGE, SCM_NALLOC, SCM_HUP_SIGNAL,

View file

@ -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> 2001-03-18 Gary Houston <ghouston@arglist.com>
* posix.c (scm_tmpnam): check that return value from tmpnam is not * posix.c (scm_tmpnam): check that return value from tmpnam is not

View file

@ -2630,7 +2630,7 @@ scm_init_storage ()
SCM_SETCDR (scm_undefineds, scm_undefineds); SCM_SETCDR (scm_undefineds, scm_undefineds);
scm_listofnull = scm_cons (SCM_EOL, SCM_EOL); 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); scm_nullvect = scm_c_make_vector (0, SCM_UNDEFINED);
#define DEFAULT_SYMHASH_SIZE 277 #define DEFAULT_SYMHASH_SIZE 277

View file

@ -1,5 +1,5 @@
/* GDB interface for Guile /* 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 * 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 * it under the terms of the GNU General Public License as published by
@ -329,7 +329,7 @@ scm_init_gdbint ()
s); s);
gdb_input_port = scm_permanent_object (port); 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));
} }
/* /*

View file

@ -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 * 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 * 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 k = 0;
scm_sizet radct = 0; scm_sizet radct = 0;
SCM_BIGDIG radpow = 1, radmod = 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; char *s = SCM_STRING_CHARS (ss), c;
while ((long) radpow * radix < SCM_BIGRAD) while ((long) radpow * radix < SCM_BIGRAD)
{ {

View file

@ -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 * 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 * 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) if (pt->read_buf == pt->putback_buf)
count += pt->saved_read_end - pt->saved_read_pos; 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); scm_take_from_input_buffers (port, SCM_STRING_CHARS (result), count);
return result; return result;

View file

@ -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 * 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 * 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; return SCM_EOF_VAL;
scm_ungetc (c, port); scm_ungetc (c, port);
tok_buf = scm_makstr (30L, 0); tok_buf = scm_allocate_string (30);
return scm_lreadr (&tok_buf, port, &copy); return scm_lreadr (&tok_buf, port, &copy);
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -127,7 +127,7 @@ char *
scm_grow_tok_buf (SCM *tok_buf) scm_grow_tok_buf (SCM *tok_buf)
{ {
unsigned long int oldlen = SCM_STRING_LENGTH (*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; unsigned long int i;
for (i = 0; i != oldlen; ++i) for (i = 0; i != oldlen; ++i)

View file

@ -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 * 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 * 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); long i = scm_ilength (chrs);
SCM_ASSERT (i >= 0, chrs, SCM_ARGn, FUNC_NAME); 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 #undef FUNC_NAME
#if (SCM_DEBUG_DEPRECATED == 0)
SCM SCM
scm_makstr (long len, int dummy) scm_makstr (long len, int dummy)
@ -146,6 +147,7 @@ scm_makstr (long len, int dummy)
} }
#undef FUNC_NAME #undef FUNC_NAME
#endif /* SCM_DEBUG_DEPRECATED == 0 */
/* converts C scm_array of strings to SCM scm_list of strings. */ /* converts C scm_array of strings to SCM scm_list of strings. */
/* If argc < 0, a null terminated scm_array is assumed. */ /* If argc < 0, a null terminated scm_array is assumed. */
@ -199,7 +201,7 @@ scm_take0str (char *s)
SCM SCM
scm_makfromstr (const char *src, scm_sizet len, int dummy) 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); char *dst = SCM_STRING_CHARS (s);
while (len--) 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_DEFINE (scm_make_string, "make-string", 1, 1, 0,
(SCM k, SCM chr), (SCM k, SCM chr),
"Return a newly allocated string of\n" "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); SCM_ASSERT_RANGE (1, k, i >= 0);
res = scm_makstr (i, 0); res = scm_allocate_string (i);
if (!SCM_UNBNDP (chr)) if (!SCM_UNBNDP (chr))
{ {
unsigned char *dst; unsigned char *dst;
@ -348,7 +371,7 @@ SCM_DEFINE (scm_string_append, "string-append", 0, 0, 1,
SCM_VALIDATE_STRING (SCM_ARGn,s); SCM_VALIDATE_STRING (SCM_ARGn,s);
i += SCM_STRING_LENGTH (s); i += SCM_STRING_LENGTH (s);
} }
res = scm_makstr (i, 0); res = scm_allocate_string (i);
data = SCM_STRING_UCHARS (res); data = SCM_STRING_UCHARS (res);
for (l = args;SCM_NIMP (l);l = SCM_CDR (l)) { for (l = args;SCM_NIMP (l);l = SCM_CDR (l)) {
s = SCM_CAR (l); s = SCM_CAR (l);

View file

@ -70,13 +70,13 @@
extern SCM scm_string_p (SCM x); extern SCM scm_string_p (SCM x);
extern SCM scm_read_only_string_p (SCM x); extern SCM scm_read_only_string_p (SCM x);
extern SCM scm_string (SCM chrs); extern SCM scm_string (SCM chrs);
extern SCM scm_makstr (long len, int);
extern SCM scm_makfromstrs (int argc, char **argv); extern SCM scm_makfromstrs (int argc, char **argv);
extern SCM scm_take_str (char *s, int len); extern SCM scm_take_str (char *s, int len);
extern SCM scm_take0str (char *s); extern SCM scm_take0str (char *s);
extern SCM scm_makfromstr (const char *src, scm_sizet len, int); extern SCM scm_makfromstr (const char *src, scm_sizet len, int);
extern SCM scm_makfrom0str (const char *src); extern SCM scm_makfrom0str (const char *src);
extern SCM scm_makfrom0str_opt (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_make_string (SCM k, SCM chr);
extern SCM scm_string_length (SCM str); extern SCM scm_string_length (SCM str);
extern SCM scm_string_ref (SCM str, SCM k); 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 (SCM_CDDR (x)) + SCM_INUM (SCM_CADR (x)) \
: (char *) SCM_CELL_WORD_1 (x)) : (char *) SCM_CELL_WORD_1 (x))
extern SCM scm_make_shared_substring (SCM str, SCM frm, SCM to); extern SCM scm_make_shared_substring (SCM str, SCM frm, SCM to);
extern SCM scm_makstr (long len, int);
#endif /* SCM_DEBUG_DEPRECATED == 0 */ #endif /* SCM_DEBUG_DEPRECATED == 0 */

View file

@ -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 * 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 * 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) st_resize_port (scm_port *pt, off_t new_size)
{ {
SCM old_stream = SCM_PACK (pt->stream); 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 old_size = SCM_STRING_LENGTH (old_stream);
unsigned long int min_size = min (old_size, new_size); unsigned long int min_size = min (old_size, new_size);
unsigned long int i; unsigned long int i;
@ -323,7 +323,7 @@ SCM_DEFINE (scm_object_to_string, "object->string", 1, 1, 0,
if (!SCM_UNBNDP (printer)) if (!SCM_UNBNDP (printer))
SCM_VALIDATE_PROC (2, 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); port = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_WRTNG, FUNC_NAME);
if (SCM_UNBNDP (printer)) if (SCM_UNBNDP (printer))

View file

@ -186,7 +186,7 @@ scm_make_uve (long k, SCM prot)
else if (SCM_CHARP (prot)) else if (SCM_CHARP (prot))
{ {
i = sizeof (char) * k; i = sizeof (char) * k;
return scm_makstr (i, 0); return scm_allocate_string (i);
} }
else if (SCM_INUMP (prot)) else if (SCM_INUMP (prot))
{ {