From f629b24506aac016dee80511e8259a7849a72b96 Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Fri, 30 Sep 2005 14:53:52 +0000
Subject: [PATCH] For all intents and purposes, pathnames with :version nil and
 :version :newest are equivalent in CMUCL.

src/pathname.lisp:
o Make EQUAL compare pathnames such that version nil and :newest are
  equal.

src/hash-new.lisp:
o Adjust sxhash to treat :version nil and :newest the same.  (Version
  :newest is hashed as if it were nil.)
---
 code/hash-new.lisp |  7 +++++--
 code/pathname.lisp | 12 +++++++++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/code/hash-new.lisp b/code/hash-new.lisp
index de9f276b8..61411e8f9 100644
--- a/code/hash-new.lisp
+++ b/code/hash-new.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/hash-new.lisp,v 1.34 2005/09/26 19:59:55 rtoy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/hash-new.lisp,v 1.35 2005/09/30 14:53:52 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -924,7 +924,10 @@
        (sxmash hash (internal-sxhash (%pathname-directory s-expr) depth))
        (sxmash hash (internal-sxhash (%pathname-name s-expr) depth))
        (sxmash hash (internal-sxhash (%pathname-type s-expr) depth))
-       (sxmash hash (internal-sxhash (%pathname-version s-expr) depth))))
+       ;; Hash :newest the same as NIL because EQUAL for pathnames
+       ;; assumes that :newest and nil are equal.
+       (let ((version (%pathname-version s-expr)))
+	 (sxmash hash (internal-sxhash (if (eql version :newest) nil version) depth)))))
     (instance
      (if (or (typep s-expr 'structure-object)
 	     (typep s-expr 'condition))
diff --git a/code/pathname.lisp b/code/pathname.lisp
index 85b184a03..cdc4772ad 100644
--- a/code/pathname.lisp
+++ b/code/pathname.lisp
@@ -4,7 +4,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/pathname.lisp,v 1.81 2005/09/27 21:17:02 rtoy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/pathname.lisp,v 1.82 2005/09/30 14:53:52 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -423,6 +423,12 @@
 	      (compare-component (car this) (car that))
 	      (compare-component (cdr this) (cdr that)))))))
 
+;; Compare the version component.  We treat NIL to be EQUAL to
+;; :NEWEST.
+(defun compare-version-component (this that)
+  (or (eql this that)
+      (and (null this) (eq that :newest))
+      (and (null that) (eq this :newest))))
 
 ;;;; Pathname functions.
 
@@ -445,8 +451,8 @@
 			  (%pathname-name pathname2))
        (compare-component (%pathname-type pathname1)
 			  (%pathname-type pathname2))
-       (compare-component (%pathname-version pathname1)
-			  (%pathname-version pathname2))))
+       (compare-version-component (%pathname-version pathname1)
+				  (%pathname-version pathname2))))
 
 ;;; WITH-PATHNAME -- Internal
 ;;;   Converts the expr, a pathname designator (a pathname, or string, or 
-- 
GitLab