Skip to content

Commit

Permalink
fix JuliaLang#3553, include of unreadable file
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 28, 2013
1 parent 5621677 commit f8c13b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,12 @@ DLLEXPORT jl_value_t *jl_parse_string(const char *str, int pos0, int greedy)
return result;
}

void jl_start_parsing_file(const char *fname)
int jl_start_parsing_file(const char *fname)
{
value_t s = cvalue_static_cstring(fname);
fl_applyn(1, symbol_value(symbol("jl-parse-file")), s);
if (fl_applyn(1, symbol_value(symbol("jl-parse-file")), s) == FL_F)
return 1;
return 0;
}

void jl_stop_parsing()
Expand Down
5 changes: 4 additions & 1 deletion src/jlfrontend.scm
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@
(jl-parser-set-stream filename (open-input-string str)))

(define (jl-parse-file s)
(jl-parser-set-stream s (open-input-file s)))
(trycatch
(begin (jl-parser-set-stream s (open-input-file s))
#t)
(lambda (e) #f)))

(define *filename-stack* '())
(define *ts-stack* '())
Expand Down
2 changes: 1 addition & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ DLLEXPORT void jl_restore_system_image(char *fname);
// front end interface
DLLEXPORT jl_value_t *jl_parse_input_line(const char *str);
DLLEXPORT jl_value_t *jl_parse_string(const char *str, int pos0, int greedy);
void jl_start_parsing_file(const char *fname);
int jl_start_parsing_file(const char *fname);
void jl_stop_parsing();
jl_value_t *jl_parse_next();
DLLEXPORT void jl_load_file_string(const char *text, char *filename);
Expand Down
4 changes: 3 additions & 1 deletion src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ void jl_load(const char *fname)
if (jl_stat(fpath, (char*)&stbuf) != 0 || (stbuf.st_mode & S_IFMT) != S_IFREG) {
jl_errorf("could not open file %s", fpath);
}
jl_start_parsing_file(fpath);
if (jl_start_parsing_file(fpath) != 0) {
jl_errorf("could not open file %s", fpath);
}
jl_parse_eval_all(fpath);
if (fpath != fname) free(fpath);
if (jl_current_module == jl_base_module) {
Expand Down

0 comments on commit f8c13b6

Please sign in to comment.