summaryrefslogtreecommitdiffstats
path: root/byte.scm
diff options
context:
space:
mode:
Diffstat (limited to 'byte.scm')
-rw-r--r--byte.scm31
1 files changed, 23 insertions, 8 deletions
diff --git a/byte.scm b/byte.scm
index 2d410bd..c611cf0 100644
--- a/byte.scm
+++ b/byte.scm
@@ -1,5 +1,5 @@
;;; "byte.scm" small integers, not necessarily chars.
-; Copyright (C) 2001, 2002, 2003 Aubrey Jaffer
+; Copyright (C) 2001, 2002, 2003, 2006 Aubrey Jaffer
;
;Permission to copy this software, to modify it, to redistribute it,
;to distribute modified versions, and to use it for any purpose is
@@ -77,6 +77,17 @@
;;Returns a newly allocated copy of the given @1.
(define bytes-copy string-copy)
+;;@args bytes start end
+;;@1 must be a bytes, and @2 and @3
+;;must be exact integers satisfying
+;;
+;;@center 0 <= @2 <= @3 <= @w{@t{(bytes-length @1)@r{.}}}
+;;
+;;@0 returns a newly allocated bytes formed from the bytes of
+;;@1 beginning with index @2 (inclusive) and ending with index
+;;@3 (exclusive).
+(define subbytes substring)
+
;;@body
;;Reverses the order of byte-array @1.
(define (bytes-reverse! bytes)
@@ -149,8 +160,8 @@
(let* ((len (abs n))
(byts (make-bytes len))
(cnt (if (positive? n)
- (apply substring-read! byts 0 n port)
- (apply substring-read! byts (- n) 0 port))))
+ (apply subbytes-read! byts 0 n port)
+ (apply subbytes-read! byts (- n) 0 port))))
(if (= cnt len)
byts
(if (positive? n)
@@ -168,11 +179,11 @@
;;by @code{current-output-port}.
(define (write-bytes bytes n . port)
(if (positive? n)
- (apply substring-write bytes 0 n port)
- (apply substring-write bytes (- n) 0 port)))
+ (apply subbytes-write bytes 0 n port)
+ (apply subbytes-write bytes (- n) 0 port)))
;;@noindent
-;;@code{substring-read!} and @code{substring-write} provide
+;;@code{subbytes-read!} and @code{subbytes-write} provide
;;lower-level procedures for reading and writing blocks of bytes. The
;;relative size of @var{start} and @var{end} determines the order of
;;writing.
@@ -185,7 +196,7 @@
;;
;;@4 may be omitted, in which case it defaults to the value returned
;;by @code{current-input-port}.
-(define (substring-read! string start end . port)
+(define (subbytes-read! string start end . port)
(if (>= end start)
(do ((idx start (+ 1 idx)))
((>= idx end) idx)
@@ -211,7 +222,7 @@
;;
;;@4 may be omitted, in which case it defaults to the value returned
;;by @code{current-output-port}.
-(define (substring-write string start end . port)
+(define (subbytes-write string start end . port)
(if (>= end start)
(do ((idx start (+ 1 idx)))
((>= idx end) (- end start))
@@ -219,3 +230,7 @@
(do ((idx (+ -1 start) (+ -1 idx)))
((< idx end) (- start end))
(apply write-byte (byte-ref string idx) port))))
+
+;;;; Legacy names.
+(define substring-read! subbytes-read!)
+(define substring-write subbytes-write)