fix problem with (open-input-file #:for-module? #f ...)

Also, clarify failure handling in the docs.

Closes #1298
This commit is contained in:
Matthew Flatt 2016-04-16 10:25:07 -06:00
parent a6e773f69b
commit 4cc3aad30b
2 changed files with 11 additions and 2 deletions

View File

@ -95,8 +95,14 @@ to close it more automatically (see @secref["willexecutor"]).
A @tech{path} value that is the @tech{cleanse}d version of A @tech{path} value that is the @tech{cleanse}d version of
@racket[path] is used as the name of the opened port. @racket[path] is used as the name of the opened port.
If opening the file fails, if @racket[for-module?] is true, and If opening the file fails due to an error in the filesystem,
then @exnraise[exn:fail:filesystem:errno]---as long as
@racket[for-module?] is @racket[#f],
@racket[current-module-path-for-load] has a non-@racket[#f] value, or
the filesystem error is not recognized as a file-not-found error. Otherwise,
when @racket[for-module?] is true,
@racket[current-module-path-for-load] has a non-@racket[#f] value, @racket[current-module-path-for-load] has a non-@racket[#f] value,
and the filesystem error is recognized as a file-not-found error,
then the raised exception is either then the raised exception is either
@racket[exn:fail:syntax:missing-module] (if the value of @racket[exn:fail:syntax:missing-module] (if the value of
@racket[current-module-path-for-load] is a @tech{syntax object}) or @racket[current-module-path-for-load] is a @tech{syntax object}) or
@ -194,6 +200,9 @@ to close it more automatically (see @secref["willexecutor"]).
A @tech{path} value that is the @tech{cleanse}d version of A @tech{path} value that is the @tech{cleanse}d version of
@racket[path] is used as the name of the opened port. @racket[path] is used as the name of the opened port.
If opening the file fails due to an error in the underlying filesystem
then @exnraise[exn:fail:filesystem:errno].
@file-examples[ @file-examples[
(define out (open-output-file some-file)) (define out (open-output-file some-file))
(write "hello world" out) (write "hello world" out)

View File

@ -4660,7 +4660,7 @@ scheme_do_open_input_file(char *name, int offset, int argc, Scheme_Object *argv[
for_module = 1; for_module = 1;
} else if (SAME_OBJ(argv[i], scheme_none_symbol)) { } else if (SAME_OBJ(argv[i], scheme_none_symbol)) {
mm_set++; mm_set++;
for_module = 1; for_module = 0;
} else { } else {
char *astr; char *astr;
intptr_t alen; intptr_t alen;