diff options
-rw-r--r-- | libguile/load.c | 9 | ||||
-rw-r--r-- | module/ice-9/boot-9.scm | 5 |
2 files changed, 13 insertions, 1 deletions
diff --git a/libguile/load.c b/libguile/load.c index b06fd7730..3b6ba2b38 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -806,6 +806,11 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1, SCM filename, exception_on_not_found; SCM full_filename, compiled_filename; int compiled_is_fallback = 0; + SCM hook = *scm_loc_load_hook; + + if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) + SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", + SCM_EOL); if (scm_is_string (args)) { @@ -870,6 +875,10 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1, return SCM_BOOL_F; } + if (!scm_is_false (hook)) + scm_call_1 (hook, (scm_is_true (full_filename) + ? full_filename : compiled_filename)); + if (scm_is_false (full_filename) || (scm_is_true (compiled_filename) && compiled_is_fresh (full_filename, compiled_filename))) diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index a70b9f71e..24f63f592 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -3526,7 +3526,10 @@ module '(ice-9 q) '(make-q q-length))}." (and go-path (fresh-compiled-file-name abs-path go-path))))))) (if cfn - (load-compiled cfn) + (begin + (if %load-hook + (%load-hook abs-path)) + (load-compiled cfn)) (start-stack 'load-stack (primitive-load abs-path))))) |