Skip to content
Snippets Groups Projects
Commit 7512b6af authored by pmai's avatar pmai
Browse files

REQUIRE and PROVIDE are not allowed to downcase symbolic module

names.  This change fixes that.  For undefined modules, require now
defaults to loading "modules:MODULENAME-library", where MODULENAME
is treated as if specified in :CASE :COMMON, so that users can use
(require :clx) or (require "CLX") to load "modules:clx-library", etc.
parent 445ae873
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/module.lisp,v 1.6 1998/07/16 13:30:49 pw Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/module.lisp,v 1.7 2001/12/11 00:44:23 pmai Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
(defun provide (module-name) (defun provide (module-name)
"Adds a new module name to *modules* indicating that it has been loaded. "Adds a new module name to *modules* indicating that it has been loaded.
Module-name may be either a case-sensitive string or a symbol; if it is Module-name may be any valid string designator. All comparisons are
a symbol, its print name is downcased and used." done using string=, i.e. module names are case-sensitive."
(pushnew (module-name-string module-name) *modules* :test #'string=) (pushnew (module-name-string module-name) *modules* :test #'string=)
t) t)
...@@ -69,32 +69,42 @@ ...@@ -69,32 +69,42 @@
needs to be. If pathname is not supplied, then a list of files are needs to be. If pathname is not supplied, then a list of files are
looked for that were registered by a EXT:DEFMODULE form. If the module looked for that were registered by a EXT:DEFMODULE form. If the module
has not been defined, then a file will be loaded whose name is formed has not been defined, then a file will be loaded whose name is formed
by merging \"modules:\" and module-name (downcased if it is a symbol). by merging \"modules:\" and the concatenation of module-name with the
This merged name will be probed with both a .lisp and .fasl extensions, suffix \"-LIBRARY\". Note that both the module-name and the suffix are
calling LOAD each, separately, converted from :case :common to :case :local. This
if it exists. While loading any files, *load-verbose* is bound to merged name will be probed with both a .lisp and .fasl extensions,
*require-verbose* which defaults to nil." calling LOAD if it exists. While loading any files, *load-verbose* is
bound to *require-verbose* which defaults to nil."
(setf module-name (module-name-string module-name)) (setf module-name (module-name-string module-name))
(unless (member module-name *modules* :test #'string=) (unless (member module-name *modules* :test #'string=)
(if pathname (let ((files (or (when pathname
(unless (listp pathname) (setf pathname (list pathname))) (if (consp pathname) pathname (list pathname)))
(let ((files (module-files module-name))) (module-files module-name)
(if files (list (module-default-pathname module-name))))
(setf pathname files) (*load-verbose* *require-verbose*))
(setf pathname (list (merge-pathnames "modules:" module-name)))))) (let ((*load-verbose* *require-verbose*)) (dolist (file files t)
(dolist (ele pathname t) (load file)))))
(load ele)))))
;;;; Misc. ;;;; Misc.
(defun module-name-string (name) (defun module-name-string (name)
(typecase name "Coerce a string designator to a module name."
(string name) (string name))
(symbol (string-downcase (symbol-name name)))
(t (error 'simple-type-error (defun module-default-pathname (module-name)
:datum name "Derive a default pathname to try to load for an undefined module
:expected-type '(or string symbol) named module-name. The default pathname is constructed from the
:format-control "Module name must be a string or symbol -- ~S." module-name by appending the suffix \"-LIBRARY\" to it, and merging
:format-arguments (list name))))) with \"modules:\". Note that both the module-name and the suffix are
each, separately, converted from :case :common to :case :local."
(let* ((module-pathname (make-pathname :name module-name :case :common))
(library-pathname (make-pathname :name "-LIBRARY" :case :common)))
(merge-pathnames
"modules:"
(make-pathname :name
(concatenate 'string
(pathname-name module-pathname :case :local)
(pathname-name library-pathname :case :local))
:case :local))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment