asdf bug: duplicate component names

Peter Van Eynde <[email protected]>
Newsgroups gmane.lisp.cclan.general
Message-ID <[email protected]>
Hello,

A debian user created an asdf system file with a lot of duplicate module
names. This causes severe problems as the dependencies are on the name of
the component. See debian bug 304972 and probably also 304970.

This is fixed with the attached patch.

BTW: what is the relation between the cclan asdf and the one in sbcl contrib?

Groetjes, Peter
DIFF (text/plain, 1.8 KB)
--- /home/pvaneynd/fakeroot/Packages/cl-asdf-1.86/asdf.lisp	2004-08-05 05:18:32.000000000 +0200
+++ asdf.lisp	2005-05-09 12:13:20.000000000 +0200
@@ -95,7 +95,8 @@
 	   #:missing-component
 	   #:missing-dependency
 	   #:circular-dependency	; errors
-
+	   #:duplicate-names
+	   
 	   #:retry
 	   #:accept                     ; restarts
 	   
@@ -157,6 +158,9 @@
 (define-condition circular-dependency (system-definition-error)
   ((components :initarg :components :reader circular-dependency-components)))
 
+(define-condition duplicate-names (system-definition-error)
+  ((name :initarg :name :reader duplicate-names-name)))
+
 (define-condition missing-component (system-definition-error)
   ((requires :initform "(unnamed)" :reader missing-requires :initarg :requires)
    (version :initform nil :reader missing-version :initarg :version)
@@ -930,6 +934,11 @@
 	      ;; list ends
 	      &allow-other-keys) options
     (check-component-input type name depends-on components in-order-to)
+
+    (when (and parent
+	     (find-component parent name))
+      (error 'duplicate-names :name name))
+    
     (let* ((other-args (remove-keys
 			'(components pathname default-component-class
 			  perform explain output-files operation-done-p
@@ -958,7 +967,19 @@
 		      for c = (parse-component-form ret c-form)
 		      collect c
 		      if serial
-		      do (push (component-name c) *serial-depends-on*)))))
+		      do (push (component-name c) *serial-depends-on*))))
+
+	;; check for duplicate names
+	(let ((name-hash (make-hash-table :test #'equalp)))
+	  (loop for c in (module-components ret)
+		do
+		(if (gethash (component-name c)
+			     name-hash)
+		    (error 'duplicate-names
+			   :name (component-name c))
+		  (setf (gethash (component-name c)
+				 name-hash)
+			t)))))
       
       (setf (slot-value ret 'in-order-to)
 	    (union-of-dependencies
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.