summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS37
-rw-r--r--ice-9/ChangeLog11
-rw-r--r--ice-9/Makefile.am2
-rw-r--r--ice-9/boot-9.scm154
-rw-r--r--ice-9/lineio.scm3
-rw-r--r--ice-9/rdelim.scm173
6 files changed, 218 insertions, 162 deletions
diff --git a/NEWS b/NEWS
index bc449f706..0b32f0514 100644
--- a/NEWS
+++ b/NEWS
@@ -8,9 +8,7 @@ Changes since Guile 1.4:
* Changes to the distribution
-** New modules (oop goops) etc
-
-The new modules
+** New modules (oop goops) etc.:
(oop goops)
(oop goops describe)
@@ -18,14 +16,8 @@ The new modules
(oop goops active-slot)
(oop goops composite-slot)
-plus some GOOPS utility modules have been added.
-
-* Changes to the stand-alone interpreter
-
-** GOOPS has been merged into Guile
-
-The Guile Object Oriented Programming System has been integrated into
-Guile.
+The Guile Object Oriented Programming System (GOOPS) has been
+integrated into Guile.
Type
@@ -75,6 +67,27 @@ Asking for the type of an object
See further in the GOOPS tutorial available in the guile-doc
distribution in info (goops.info) and texinfo formats.
+** New module (ice-9 rdelim).
+
+This exports the following procedures which were previously defined
+in the root module:
+
+read-line read-line! read-delimited read-delimited!
+;; TODO: read-string!/partial %read-delimited! %read-line write-line
+
+For backwards compatibility the definitions are also imported into the
+root module in this version of Guile. However you should add:
+
+(use-modules (ice-9 rdelim))
+
+to any program which uses the definitions, since this may be removed
+in in a future version.
+
+Alternatively, if guile-scsh is installed, the (scsh rdelim) module
+can be used for similar functionality.
+
+* Changes to the stand-alone interpreter
+
** It's now possible to create modules with controlled environments
Example:
@@ -283,7 +296,7 @@ current values of file descriptors 0, 1, and 2 in the parent process.
There is no such concept as a weak binding any more.
-** Removed constants: bignum-radix
+** Removed constants: bignum-radix, scm-line-incrementors
* Changes to the gh_ interface
diff --git a/ice-9/ChangeLog b/ice-9/ChangeLog
index dc624c644..8b10caa3e 100644
--- a/ice-9/ChangeLog
+++ b/ice-9/ChangeLog
@@ -1,3 +1,14 @@
+2001-01-21 Gary Houston <ghouston@arglist.com>
+
+ * rdelim.scm: new file implementing module (ice-9 rdelim).
+ * ice-9.scm (scm-line-incrementors read-line! read-delimited!
+ read-delimited read-line): moved to rdelim.scm.
+ scm-line-incrementors is not exported.
+ * boot-9.scm: import (ice-9 rdelim) for backwards compatibility,
+ for now.
+ * lineio.scm: use module (ice-9 rdelim).
+ * Makefile.am (ice9_sources): add rdelim.scm.
+
2000-12-29 Dirk Herrmann <D.Herrmann@tu-bs.de>
* boot-9.scm (root-module-closure, scm-module-closure): Remove
diff --git a/ice-9/Makefile.am b/ice-9/Makefile.am
index 0cff73751..4580ed7c2 100644
--- a/ice-9/Makefile.am
+++ b/ice-9/Makefile.am
@@ -28,7 +28,7 @@ ice9_sources = \
format.scm getopt-long.scm hcons.scm lineio.scm ls.scm \
mapping.scm networking.scm null.scm optargs.scm poe.scm popen.scm \
posix.scm psyntax.pp psyntax.ss q.scm r4rs.scm r5rs.scm \
- receive.scm srfi-8.scm \
+ rdelim.scm receive.scm srfi-8.scm \
regex.scm runq.scm safe-r5rs.scm safe.scm session.scm slib.scm \
streams.scm string-fun.scm syncase.scm tags.scm threads.scm
diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm
index c6a48099a..d1e37185f 100644
--- a/ice-9/boot-9.scm
+++ b/ice-9/boot-9.scm
@@ -166,152 +166,6 @@
-;;; {Line and Delimited I/O}
-
-;;; corresponds to SCM_LINE_INCREMENTORS in libguile.
-(define scm-line-incrementors "\n")
-
-(define (read-line! string . maybe-port)
- (let* ((port (if (pair? maybe-port)
- (car maybe-port)
- (current-input-port))))
- (let* ((rv (%read-delimited! scm-line-incrementors
- string
- #t
- port))
- (terminator (car rv))
- (nchars (cdr rv)))
- (cond ((and (= nchars 0)
- (eof-object? terminator))
- terminator)
- ((not terminator) #f)
- (else nchars)))))
-
-(define (read-delimited! delims buf . args)
- (let* ((num-args (length args))
- (port (if (> num-args 0)
- (car args)
- (current-input-port)))
- (handle-delim (if (> num-args 1)
- (cadr args)
- 'trim))
- (start (if (> num-args 2)
- (caddr args)
- 0))
- (end (if (> num-args 3)
- (cadddr args)
- (string-length buf))))
- (let* ((rv (%read-delimited! delims
- buf
- (not (eq? handle-delim 'peek))
- port
- start
- end))
- (terminator (car rv))
- (nchars (cdr rv)))
- (cond ((or (not terminator) ; buffer filled
- (eof-object? terminator))
- (if (zero? nchars)
- (if (eq? handle-delim 'split)
- (cons terminator terminator)
- terminator)
- (if (eq? handle-delim 'split)
- (cons nchars terminator)
- nchars)))
- (else
- (case handle-delim
- ((trim peek) nchars)
- ((concat) (string-set! buf (+ nchars start) terminator)
- (+ nchars 1))
- ((split) (cons nchars terminator))
- (else (error "unexpected handle-delim value: "
- handle-delim))))))))
-
-(define (read-delimited delims . args)
- (let* ((port (if (pair? args)
- (let ((pt (car args)))
- (set! args (cdr args))
- pt)
- (current-input-port)))
- (handle-delim (if (pair? args)
- (car args)
- 'trim)))
- (let loop ((substrings ())
- (total-chars 0)
- (buf-size 100)) ; doubled each time through.
- (let* ((buf (make-string buf-size))
- (rv (%read-delimited! delims
- buf
- (not (eq? handle-delim 'peek))
- port))
- (terminator (car rv))
- (nchars (cdr rv))
- (join-substrings
- (lambda ()
- (apply string-append
- (reverse
- (cons (if (and (eq? handle-delim 'concat)
- (not (eof-object? terminator)))
- (string terminator)
- "")
- (cons (substring buf 0 nchars)
- substrings))))))
- (new-total (+ total-chars nchars)))
- (cond ((not terminator)
- ;; buffer filled.
- (loop (cons (substring buf 0 nchars) substrings)
- new-total
- (* buf-size 2)))
- ((eof-object? terminator)
- (if (zero? new-total)
- (if (eq? handle-delim 'split)
- (cons terminator terminator)
- terminator)
- (if (eq? handle-delim 'split)
- (cons (join-substrings) terminator)
- (join-substrings))))
- (else
- (case handle-delim
- ((trim peek concat) (join-substrings))
- ((split) (cons (join-substrings) terminator))
-
-
- (else (error "unexpected handle-delim value: "
- handle-delim)))))))))
-
-;;; read-line [PORT [HANDLE-DELIM]] reads a newline-terminated string
-;;; from PORT. The return value depends on the value of HANDLE-DELIM,
-;;; which may be one of the symbols `trim', `concat', `peek' and
-;;; `split'. If it is `trim' (the default), the trailing newline is
-;;; removed and the string is returned. If `concat', the string is
-;;; returned with the trailing newline intact. If `peek', the newline
-;;; is left in the input port buffer and the string is returned. If
-;;; `split', the newline is split from the string and read-line
-;;; returns a pair consisting of the truncated string and the newline.
-
-(define (read-line . args)
- (let* ((port (if (null? args)
- (current-input-port)
- (car args)))
- (handle-delim (if (> (length args) 1)
- (cadr args)
- 'trim))
- (line/delim (%read-line port))
- (line (car line/delim))
- (delim (cdr line/delim)))
- (case handle-delim
- ((trim) line)
- ((split) line/delim)
- ((concat) (if (and (string? line) (char? delim))
- (string-append line (string delim))
- line))
- ((peek) (if (char? delim)
- (unread-char delim port))
- line)
- (else
- (error "unexpected handle-delim value: " handle-delim)))))
-
-
;;; {Arrays}
;;;
@@ -2483,6 +2337,7 @@
(read (current-input-port))))
(define (scm-style-repl)
+
(letrec (
(start-gc-rt #f)
(start-rt #f)
@@ -2770,6 +2625,7 @@
+
;;; {Load emacs interface support if emacs option is given.}
(define (load-emacs-interface)
@@ -2779,14 +2635,16 @@
+;; temporary, for backwards compatibility.
+(use-modules (ice-9 rdelim))
+
+
(define using-readline?
(let ((using-readline? (make-fluid)))
(make-procedure-with-setter
(lambda () (fluid-ref using-readline?))
(lambda (v) (fluid-set! using-readline? v)))))
-;; this is just (scm-style-repl) with a wrapper to install and remove
-;; signal handlers.
(define (top-repl)
;; Load emacs interface support if emacs option is given.
diff --git a/ice-9/lineio.scm b/ice-9/lineio.scm
index e40b89353..25711f8c3 100644
--- a/ice-9/lineio.scm
+++ b/ice-9/lineio.scm
@@ -20,7 +20,8 @@
-(define-module (ice-9 lineio))
+(define-module (ice-9 lineio)
+ :use-module (ice-9 readline))
;;; {Line Buffering Input Ports}
diff --git a/ice-9/rdelim.scm b/ice-9/rdelim.scm
new file mode 100644
index 000000000..c6d6b2aa8
--- /dev/null
+++ b/ice-9/rdelim.scm
@@ -0,0 +1,173 @@
+;;; installed-scm-file
+
+;;;; Copyright (C) 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
+;;;; the Free Software Foundation; either version 2, or (at your option)
+;;;; any later version.
+;;;;
+;;;; This program is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with this software; see the file COPYING. If not, write to
+;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+;;;; Boston, MA 02111-1307 USA
+;;;;
+
+
+;;; Module for delimited I/O. This is similar to (scsh rdelim) but is
+;;; somewhat incompatible.
+
+(define-module (ice-9 rdelim))
+
+(export read-line read-line! read-delimited read-delimited!)
+;; TODO: split the C part of this module out of libguile and into its
+;; own top-level directory.
+;; (export read-string!/partial %read-delimited! %read-line write-line)
+
+(define (read-line! string . maybe-port)
+ ;; corresponds to SCM_LINE_INCREMENTORS in libguile.
+ (define scm-line-incrementors "\n")
+
+ (let* ((port (if (pair? maybe-port)
+ (car maybe-port)
+ (current-input-port))))
+ (let* ((rv (%read-delimited! scm-line-incrementors
+ string
+ #t
+ port))
+ (terminator (car rv))
+ (nchars (cdr rv)))
+ (cond ((and (= nchars 0)
+ (eof-object? terminator))
+ terminator)
+ ((not terminator) #f)
+ (else nchars)))))
+
+(define (read-delimited! delims buf . args)
+ (let* ((num-args (length args))
+ (port (if (> num-args 0)
+ (car args)
+ (current-input-port)))
+ (handle-delim (if (> num-args 1)
+ (cadr args)
+ 'trim))
+ (start (if (> num-args 2)
+ (caddr args)
+ 0))
+ (end (if (> num-args 3)
+ (cadddr args)
+ (string-length buf))))
+ (let* ((rv (%read-delimited! delims
+ buf
+ (not (eq? handle-delim 'peek))
+ port
+ start
+ end))
+ (terminator (car rv))
+ (nchars (cdr rv)))
+ (cond ((or (not terminator) ; buffer filled
+ (eof-object? terminator))
+ (if (zero? nchars)
+ (if (eq? handle-delim 'split)
+ (cons terminator terminator)
+ terminator)
+ (if (eq? handle-delim 'split)
+ (cons nchars terminator)
+ nchars)))
+ (else
+ (case handle-delim
+ ((trim peek) nchars)
+ ((concat) (string-set! buf (+ nchars start) terminator)
+ (+ nchars 1))
+ ((split) (cons nchars terminator))
+ (else (error "unexpected handle-delim value: "
+ handle-delim))))))))
+
+(define (read-delimited delims . args)
+ (let* ((port (if (pair? args)
+ (let ((pt (car args)))
+ (set! args (cdr args))
+ pt)
+ (current-input-port)))
+ (handle-delim (if (pair? args)
+ (car args)
+ 'trim)))
+ (let loop ((substrings ())
+ (total-chars 0)
+ (buf-size 100)) ; doubled each time through.
+ (let* ((buf (make-string buf-size))
+ (rv (%read-delimited! delims
+ buf
+ (not (eq? handle-delim 'peek))
+ port))
+ (terminator (car rv))
+ (nchars (cdr rv))
+ (join-substrings
+ (lambda ()
+ (apply string-append
+ (reverse
+ (cons (if (and (eq? handle-delim 'concat)
+ (not (eof-object? terminator)))
+ (string terminator)
+ "")
+ (cons (substring buf 0 nchars)
+ substrings))))))
+ (new-total (+ total-chars nchars)))
+ (cond ((not terminator)
+ ;; buffer filled.
+ (loop (cons (substring buf 0 nchars) substrings)
+ new-total
+ (* buf-size 2)))
+ ((eof-object? terminator)
+ (if (zero? new-total)
+ (if (eq? handle-delim 'split)
+ (cons terminator terminator)
+ terminator)
+ (if (eq? handle-delim 'split)
+ (cons (join-substrings) terminator)
+ (join-substrings))))
+ (else
+ (case handle-delim
+ ((trim peek concat) (join-substrings))
+ ((split) (cons (join-substrings) terminator))
+
+
+ (else (error "unexpected handle-delim value: "
+ handle-delim)))))))))
+
+;;; read-line [PORT [HANDLE-DELIM]] reads a newline-terminated string
+;;; from PORT. The return value depends on the value of HANDLE-DELIM,
+;;; which may be one of the symbols `trim', `concat', `peek' and
+;;; `split'. If it is `trim' (the default), the trailing newline is
+;;; removed and the string is returned. If `concat', the string is
+;;; returned with the trailing newline intact. If `peek', the newline
+;;; is left in the input port buffer and the string is returned. If
+;;; `split', the newline is split from the string and read-line
+;;; returns a pair consisting of the truncated string and the newline.
+
+(define (read-line . args)
+ (let* ((port (if (null? args)
+ (current-input-port)
+ (car args)))
+ (handle-delim (if (> (length args) 1)
+ (cadr args)
+ 'trim))
+ (line/delim (%read-line port))
+ (line (car line/delim))
+ (delim (cdr line/delim)))
+ (case handle-delim
+ ((trim) line)
+ ((split) line/delim)
+ ((concat) (if (and (string? line) (char? delim))
+ (string-append line (string delim))
+ line))
+ ((peek) (if (char? delim)
+ (unread-char delim port))
+ line)
+ (else
+ (error "unexpected handle-delim value: " handle-delim)))))