open-file-input-port and open-file-output-port now signal an error

when file-options are not enum-sets.
This commit is contained in:
Abdulaziz Ghuloum 2008-10-29 14:10:24 -04:00
parent d2022faf53
commit db2604ad2a
2 changed files with 15 additions and 9 deletions

View File

@ -1491,7 +1491,10 @@
(if (enum-set-member? 'no-create x) 1 0)
(if (enum-set-member? 'no-fail x) 2 0)
(if (enum-set-member? 'no-truncate x) 4 0)))
(let ([opt (opt->num file-options)])
(let ([opt (if (enum-set? file-options)
(opt->num file-options)
(die who "file-options is not an enum set"
file-options))])
(let ([fh (foreign-call "ikrt_open_output_fd"
(string->utf8 filename)
opt)])
@ -1508,19 +1511,22 @@
[(filename file-options buffer-mode)
(open-file-input-port filename file-options buffer-mode #f)]
[(filename file-options buffer-mode transcoder)
(define who 'open-file-input-port)
(unless (string? filename)
(die 'open-file-input-port "invalid filename" filename))
(die who "invalid filename" filename))
(unless (enum-set? file-options)
(die who "file-options is not an enum set" file-options))
(unless (or (not transcoder) (transcoder? transcoder))
(die 'open-file-input-port "invalid transcoder" transcoder))
(die who "invalid transcoder" transcoder))
; FIXME: file-options ignored
; FIXME: buffer-mode ignored
(fh->input-port
(open-input-file-handle filename 'open-file-input-port)
(open-input-file-handle filename who)
filename
input-file-buffer-size
transcoder
#t
'open-file-input-port)]))
who)]))
(define open-file-output-port
(case-lambda

View File

@ -1 +1 @@
1652
1653