mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-03 18:50:19 +02:00
* strings.h: don't use SCM_P. don't include <string.h>.
* error.c, gh_data.c, ports.c, script.c, strop.c: include <string.h>. * strings.c (scm_string_ref): make the 2nd argument compulsory. previously it defaulted to zero for no good reason that I can see. use a local variable for SCM_INUM (k). replace SCM_VALIDATE_INUM_DEF with SCM_VALIDATE_INUM_COPY. (scm_makfromstr): cosmetic changes. (scm_string): Accept only chars in the list, not strings, for conformance to R5RS (particularly for list->string, which is supposed to be the inverse of string->list.) remove SCM_DEFER_INTS/SCM_ALLOW_INTS, which is unnecessary since scm_makstr handles the cell allocation. when reporting wrong-type arg, don't report the position as 1. * posix.c (scm_init_posix): intern PIPE_BUF if it's defined. * boot-9.scm (find-and-link-dynamic-module): pass strings, not symbols, to string-append.
This commit is contained in:
parent
505ede1881
commit
bd9e24b301
13 changed files with 126 additions and 98 deletions
16
NEWS
16
NEWS
|
@ -152,6 +152,16 @@ a garbage collection before each allocation of a cell. This can
|
|||
slow down the interpreter dramatically, so the setter should be used to
|
||||
turn on this extra processing only when necessary.
|
||||
|
||||
* Changes to Scheme functions and syntax
|
||||
|
||||
** string-ref: the second argument is no longer optional.
|
||||
|
||||
** string, list->string: no longer accept strings in their arguments,
|
||||
only characters, for compatibility with R5RS.
|
||||
|
||||
** New procedure: port-closed? PORT
|
||||
Returns #t if PORT is closed or #f if it is open.
|
||||
|
||||
* Changes to the stand-alone interpreter
|
||||
|
||||
** New primitives: `pkgdata-dir', `site-dir', `library-dir'
|
||||
|
@ -182,9 +192,6 @@ at the top of the script.
|
|||
(The first options enables the debugging evaluator.
|
||||
The second enables backtraces.)
|
||||
|
||||
** New procedure: port-closed? PORT
|
||||
Returns #t if PORT is closed or #f if it is open.
|
||||
|
||||
** Attempting to get the value of an unbound variable now produces
|
||||
an exception with a key of 'unbound-variable instead of 'misc-error.
|
||||
|
||||
|
@ -221,6 +228,9 @@ removed in a future version.
|
|||
provide input or accept output. Previously only the underlying file
|
||||
descriptors were checked.
|
||||
|
||||
** New variable PIPE_BUF: the maximum number of bytes that can be
|
||||
atomically written to a pipe.
|
||||
|
||||
** If a facility is not available on the system when Guile is
|
||||
compiled, the corresponding primitive procedure will not be defined.
|
||||
Previously it would have been defined but would throw a system-error
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2000-01-30 Gary Houston <ghouston@arglist.com>
|
||||
|
||||
* boot-9.scm (find-and-link-dynamic-module): pass strings, not symbols,
|
||||
to string-append.
|
||||
|
||||
2000-01-29 Gary Houston <ghouston@arglist.com>
|
||||
|
||||
* expect.scm (expect): don't call char-ready? before expect-select,
|
||||
|
|
|
@ -1974,14 +1974,14 @@
|
|||
|
||||
(define (find-and-link-dynamic-module module-name)
|
||||
(define (make-init-name mod-name)
|
||||
(string-append 'scm_init
|
||||
(string-append "scm_init"
|
||||
(list->string (map (lambda (c)
|
||||
(if (or (char-alphabetic? c)
|
||||
(char-numeric? c))
|
||||
c
|
||||
#\_))
|
||||
(string->list mod-name)))
|
||||
'_module))
|
||||
"_module"))
|
||||
|
||||
;; Put the subdirectory for this module in the car of SUBDIR-AND-LIBNAME,
|
||||
;; and the `libname' (the name of the module prepended by `lib') in the cdr
|
||||
|
@ -2844,7 +2844,7 @@
|
|||
(sigaction (car sig-msg)
|
||||
(car old-handler)
|
||||
(cdr old-handler))))
|
||||
signals old-handlers)))))
|
||||
signals old-handlers)))))
|
||||
|
||||
(defmacro false-if-exception (expr)
|
||||
`(catch #t (lambda () ,expr)
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
2000-01-31 Gary Houston <ghouston@arglist.com>
|
||||
|
||||
* strings.h: don't use SCM_P. don't include <string.h>.
|
||||
* error.c, gh_data.c, ports.c, script.c, strop.c: include <string.h>.
|
||||
|
||||
* strings.c (scm_string_ref): make the 2nd argument compulsory.
|
||||
previously it defaulted to zero for no good reason that I can see.
|
||||
use a local variable for SCM_INUM (k). replace
|
||||
SCM_VALIDATE_INUM_DEF with SCM_VALIDATE_INUM_COPY.
|
||||
|
||||
(scm_makfromstr): cosmetic changes.
|
||||
|
||||
(scm_string): Accept only chars in the list, not strings, for
|
||||
conformance to R5RS (particularly for list->string, which is
|
||||
supposed to be the inverse of string->list.) remove
|
||||
SCM_DEFER_INTS/SCM_ALLOW_INTS, which is unnecessary since
|
||||
scm_makstr handles the cell allocation. when reporting wrong-type
|
||||
arg, don't report the position as 1.
|
||||
|
||||
* posix.c (scm_init_posix): intern PIPE_BUF if it's defined.
|
||||
|
||||
2000-01-29 Gary Houston <ghouston@arglist.com>
|
||||
|
||||
* posix.c (scm_pipe): rewrote the docstring.
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "_scm.h"
|
||||
#include "pairs.h"
|
||||
#include "genio.h"
|
||||
|
@ -53,6 +54,9 @@
|
|||
#include "scm_validate.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996, 1997, 1998, 1999, 2000 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
|
||||
|
@ -1459,7 +1459,7 @@ scm_sysintern ("F_SETOWN", scm_long2num (F_SETOWN));
|
|||
#endif
|
||||
#ifdef FD_CLOEXEC
|
||||
scm_sysintern ("FD_CLOEXEC", scm_long2num (FD_CLOEXEC));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "filesys.x"
|
||||
}
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <gh.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
/* data conversion C->scheme */
|
||||
SCM
|
||||
|
|
|
@ -56,6 +56,10 @@
|
|||
#include "scm_validate.h"
|
||||
#include "ports.h"
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
|
|
@ -173,12 +173,13 @@ SCM_DEFINE (scm_pipe, "pipe", 0, 0, 0,
|
|||
"the CDR is the output port. Data written (and flushed) to the\n"
|
||||
"output port can be read from the input port.\n"
|
||||
"Pipes are commonly used for communication with a newly\n"
|
||||
"forked child process. @code{setvbuf} can be used to remove the\n"
|
||||
"buffer from the output port: then data written will be\n"
|
||||
"available at the input port even if the output port is not\n"
|
||||
"flushed. Note that the output port is likely\n"
|
||||
"to block if too much data is written without reading from\n"
|
||||
"the input port."
|
||||
"forked child process. The need to flush the output port\n"
|
||||
"can be avoided by making it unbuffered using @code{setvbuf}.\n\n"
|
||||
"Writes occur atomically provided the size of the data in\n"
|
||||
"bytes is not greater than the value of @code{PIPE_BUF}\n"
|
||||
"Note that the output port is likely to block if too much data\n"
|
||||
"(typically equal to @code{PIPE_BUF}) has been written but not\n"
|
||||
"yet read from the input port\n"
|
||||
)
|
||||
#define FUNC_NAME s_scm_pipe
|
||||
{
|
||||
|
@ -1315,6 +1316,10 @@ scm_init_posix ()
|
|||
#ifdef LC_ALL
|
||||
scm_sysintern ("LC_ALL", SCM_MAKINUM (LC_ALL));
|
||||
#endif
|
||||
#ifdef PIPE_BUF
|
||||
scm_sysintern ("PIPE_BUF", scm_long2num (PIPE_BUF));
|
||||
#endif
|
||||
|
||||
#include "cpp_sig_symbols.c"
|
||||
#include "posix.x"
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
|
||||
#include "script.h"
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h> /* for X_OK define */
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1995,1996,1998 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995,1996,1998,2000 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
|
||||
|
@ -85,65 +85,38 @@ SCM_DEFINE (scm_read_only_string_p, "read-only-string?", 1, 0, 0,
|
|||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
SCM_REGISTER_PROC(s_list_to_string, "list->string", 1, 0, 0, scm_string);
|
||||
|
||||
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),
|
||||
"Returns a newly allocated string composed of the arguments, CHRS.")
|
||||
#define FUNC_NAME s_scm_string
|
||||
{
|
||||
SCM res;
|
||||
register unsigned char *data;
|
||||
long i;
|
||||
long len;
|
||||
SCM_DEFER_INTS;
|
||||
i = scm_ilength (chrs);
|
||||
if (i < 0)
|
||||
{
|
||||
SCM_ALLOW_INTS;
|
||||
SCM_ASSERT (0, chrs, SCM_ARG1, FUNC_NAME);
|
||||
}
|
||||
len = 0;
|
||||
{
|
||||
SCM s;
|
||||
SCM result;
|
||||
|
||||
for (len = 0, s = chrs; s != SCM_EOL; s = SCM_CDR (s))
|
||||
if (SCM_ICHRP (SCM_CAR (s)))
|
||||
len += 1;
|
||||
else if (SCM_ROSTRINGP (SCM_CAR (s)))
|
||||
len += SCM_ROLENGTH (SCM_CAR (s));
|
||||
else
|
||||
{
|
||||
SCM_ALLOW_INTS;
|
||||
SCM_ASSERT (0, s, SCM_ARG1, FUNC_NAME);
|
||||
}
|
||||
{
|
||||
long i = scm_ilength (chrs);
|
||||
|
||||
SCM_ASSERT (i >= 0, chrs, SCM_ARGn, FUNC_NAME);
|
||||
result = scm_makstr (i, 0);
|
||||
}
|
||||
res = scm_makstr (len, 0);
|
||||
data = SCM_UCHARS (res);
|
||||
for (;SCM_NNULLP (chrs);chrs = SCM_CDR (chrs))
|
||||
{
|
||||
if (SCM_ICHRP (SCM_CAR (chrs)))
|
||||
*data++ = SCM_ICHR (SCM_CAR (chrs));
|
||||
else
|
||||
{
|
||||
int l;
|
||||
char * c;
|
||||
l = SCM_ROLENGTH (SCM_CAR (chrs));
|
||||
c = SCM_ROCHARS (SCM_CAR (chrs));
|
||||
while (l)
|
||||
{
|
||||
--l;
|
||||
*data++ = *c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
SCM_ALLOW_INTS;
|
||||
return res;
|
||||
|
||||
{
|
||||
unsigned char *data = SCM_UCHARS (result);
|
||||
|
||||
while (SCM_NNULLP (chrs))
|
||||
{
|
||||
SCM elt = SCM_CAR (chrs);
|
||||
|
||||
SCM_VALIDATE_ICHR (SCM_ARGn, elt);
|
||||
*data++ = SCM_ICHR (elt);
|
||||
chrs = SCM_CDR (chrs);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
|
||||
SCM
|
||||
scm_makstr (long len, int slots)
|
||||
{
|
||||
|
@ -212,21 +185,17 @@ scm_take0str (char *s)
|
|||
return scm_take_str (s, strlen (s));
|
||||
}
|
||||
|
||||
|
||||
SCM
|
||||
scm_makfromstr (const char *src, scm_sizet len, int slots)
|
||||
{
|
||||
SCM s;
|
||||
register char *dst;
|
||||
s = scm_makstr ((long) len, slots);
|
||||
dst = SCM_CHARS (s);
|
||||
SCM s = scm_makstr (len, slots);
|
||||
char *dst = SCM_CHARS (s);
|
||||
|
||||
while (len--)
|
||||
*dst++ = *src++;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SCM
|
||||
scm_makfrom0str (const char *src)
|
||||
{
|
||||
|
@ -281,16 +250,18 @@ SCM_DEFINE (scm_string_length, "string-length", 1, 0, 0,
|
|||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
SCM_DEFINE (scm_string_ref, "string-ref", 1, 1, 0,
|
||||
SCM_DEFINE (scm_string_ref, "string-ref", 2, 0, 0,
|
||||
(SCM str, SCM k),
|
||||
"Returns character K of STR using zero-origin indexing.\n"
|
||||
"K must be a valid index of STR.")
|
||||
#define FUNC_NAME s_scm_string_ref
|
||||
{
|
||||
SCM_VALIDATE_ROSTRING (1,str);
|
||||
SCM_VALIDATE_INUM_DEF (2,k,0);
|
||||
SCM_ASSERT_RANGE (2,k,SCM_INUM (k) < SCM_ROLENGTH (str) && SCM_INUM (k) >= 0);
|
||||
return SCM_MAKICHR (SCM_ROUCHARS (str)[SCM_INUM (k)]);
|
||||
int idx;
|
||||
|
||||
SCM_VALIDATE_ROSTRING (1, str);
|
||||
SCM_VALIDATE_INUM_COPY (2, k, idx);
|
||||
SCM_ASSERT_RANGE (2, k, idx >= 0 && idx < SCM_ROLENGTH (str));
|
||||
return SCM_MAKICHR (SCM_ROUCHARS (str)[idx]);
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
|
|
|
@ -49,13 +49,9 @@
|
|||
|
||||
#include "libguile/__scm.h"
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define SCM_SLOPPY_STRINGP(x) ((SCM_TYP7S(x)==scm_tc7_string))
|
||||
#define SCM_SLOPPY_STRINGP(x) (SCM_TYP7S(x)==scm_tc7_string)
|
||||
#define SCM_STRINGP(x) (SCM_NIMP(x) && SCM_SLOPPY_STRINGP(x))
|
||||
#define SCM_NSTRINGP(x) (!SCM_STRINGP(x))
|
||||
|
||||
|
@ -66,23 +62,23 @@
|
|||
|
||||
|
||||
|
||||
extern SCM scm_string_p SCM_P ((SCM x));
|
||||
extern SCM scm_read_only_string_p SCM_P ((SCM x));
|
||||
extern SCM scm_string SCM_P ((SCM chrs));
|
||||
extern SCM scm_makstr SCM_P ((long len, int slots));
|
||||
extern SCM scm_makfromstrs SCM_P ((int argc, char **argv));
|
||||
extern SCM scm_take_str SCM_P ((char *s, int len));
|
||||
extern SCM scm_take0str SCM_P ((char *s));
|
||||
extern SCM scm_makfromstr SCM_P ((const char *src, scm_sizet len, int slots));
|
||||
extern SCM scm_makfrom0str SCM_P ((const char *src));
|
||||
extern SCM scm_makfrom0str_opt SCM_P ((const char *src));
|
||||
extern SCM scm_make_string SCM_P ((SCM k, SCM chr));
|
||||
extern SCM scm_string_length SCM_P ((SCM str));
|
||||
extern SCM scm_string_ref SCM_P ((SCM str, SCM k));
|
||||
extern SCM scm_string_set_x SCM_P ((SCM str, SCM k, SCM chr));
|
||||
extern SCM scm_substring SCM_P ((SCM str, SCM start, SCM end));
|
||||
extern SCM scm_string_append SCM_P ((SCM args));
|
||||
extern SCM scm_make_shared_substring SCM_P ((SCM str, SCM frm, SCM to));
|
||||
extern void scm_init_strings SCM_P ((void));
|
||||
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 slots);
|
||||
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 slots);
|
||||
extern SCM scm_makfrom0str (const char *src);
|
||||
extern SCM scm_makfrom0str_opt (const char *src);
|
||||
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);
|
||||
extern SCM scm_string_set_x (SCM str, SCM k, SCM chr);
|
||||
extern SCM scm_substring (SCM str, SCM start, SCM end);
|
||||
extern SCM scm_string_append (SCM args);
|
||||
extern SCM scm_make_shared_substring (SCM str, SCM frm, SCM to);
|
||||
extern void scm_init_strings (void);
|
||||
|
||||
#endif /* STRINGSH */
|
||||
|
|
|
@ -30,6 +30,11 @@ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|||
#include "scm_validate.h"
|
||||
#include "strop.h"
|
||||
#include "read.h" /*For SCM_CASE_INSENSITIVE_P*/
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue