Allow OPEN-INPUT-STRING to accept #F for optional arguments.
authorChris Hanson <org/chris-hanson/cph>
Thu, 27 Feb 2003 21:27:58 +0000 (21:27 +0000)
committerChris Hanson <org/chris-hanson/cph>
Thu, 27 Feb 2003 21:27:58 +0000 (21:27 +0000)
v7/src/runtime/strnin.scm

index 8e3006a75fc583aa76c62cc8f96ea7b0131cfec7..401058fb04c84eea180fd39f126336550b3957e7 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: strnin.scm,v 14.11 2003/02/14 18:28:34 cph Exp $
+$Id: strnin.scm,v 14.12 2003/02/27 21:27:58 cph Exp $
 
 Copyright 1988,1990,1993,1999,2003 Massachusetts Institute of Technology
 
@@ -44,24 +44,20 @@ USA.
   (with-input-from-port (open-input-string string) thunk))
 
 (define (open-input-string string #!optional start end)
+  (guarantee-string string 'OPEN-INPUT-STRING)
   (let ((end
-        (if (default-object? end)
+        (if (or (default-object? end) (not end))
             (string-length string)
-            (check-index end (string-length string) 'OPEN-INPUT-STRING))))
-    (make-port
-     input-string-port-type
-     (make-input-string-state string
-                             (if (default-object? start)
-                                 0
-                                 (check-index start end 'OPEN-INPUT-STRING))
-                             end))))
-
-(define (check-index index limit procedure)
-  (if (not (exact-nonnegative-integer? index))
-      (error:wrong-type-argument index "exact non-negative integer" procedure))
-  (if (not (<= index limit))
-      (error:bad-range-argument index procedure))
-  index)
+            (guarantee-substring-end-index end (string-length string)
+                                           'OPEN-INPUT-STRING))))
+    (make-port input-string-port-type
+              (make-input-string-state
+               string
+               (if (or (default-object? start) (not start))
+                   0
+                   (guarantee-substring-start-index start end
+                                                    'OPEN-INPUT-STRING))
+               end))))
 
 (define input-string-port-type)