warn and load source file if newer than compile file
authorAndy Wingo <wingo@pobox.com>
Sat, 9 Aug 2008 12:23:20 +0000 (14:23 +0200)
committerAndy Wingo <wingo@pobox.com>
Sat, 9 Aug 2008 12:23:20 +0000 (14:23 +0200)
* ice-9/boot-9.scm (try-module-autoload): Warn if the compiled file is
  older than the source file, and in that case load the source file.

ice-9/boot-9.scm

index 8e2aeef..5c884ce 100644 (file)
@@ -2166,14 +2166,20 @@ module '(ice-9 q) '(make-q q-length))}."
            (lambda () (autoload-in-progress! dir-hint name))
            (lambda ()
              (let ((file (in-vicinity dir-hint name)))
-               (cond ((and load-compiled
-                           (%search-load-path (string-append file ".go")))
-                      => (lambda (full)
-                           (load-file load-compiled full)))
-                     ((%search-load-path file)
-                      => (lambda (full)
-                           (with-fluids ((current-reader #f))
-                             (load-file primitive-load full)))))))
+                (let ((compiled (and load-compiled
+                                     (%search-load-path
+                                      (string-append file ".go"))))
+                      (source (%search-load-path file)))
+                  (cond ((and source
+                              (or (not compiled)
+                                  (< (stat:mtime (stat compiled))
+                                     (stat:mtime (stat source)))))
+                         (if compiled
+                             (warn "source file" source "newer than" compiled))
+                         (with-fluids ((current-reader #f))
+                           (load-file primitive-load source)))
+                        (compiled
+                         (load-file load-compiled compiled))))))
            (lambda () (set-autoloaded! dir-hint name didit)))
           didit))))