[armedbear-cvs] r13291 - trunk/abcl/src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Sat Jun 4 20:26:14 UTC 2011


Author: mevenson
Date: Tue May 24 05:25:05 2011
New Revision: 13291

Log:
Reimplement the logic MERGE-PATHNAMES for Pathname version.

I started from scratch interpreting these two passages from the CLHS
Function MERGE-PATHNAMES entry:

"If no version is supplied, default-version is used. If
default-version is nil, the version component will remain unchanged."

"If pathname does not specify a name, then the version, if not
provided, will come from default-pathname, just like the other
components. If pathname does specify a name, then the version is not
affected by default-pathname. If this process leaves the version
missing, the default-version is used."

The previous logic was certainly not obeying the rule where if the
default-version was nil.  Redoing the logic to paraphase the
specification seemed simpler than trying to drawing the corresponding
logic tree and laboriously checking all the cases.

Modified:
   trunk/abcl/src/org/armedbear/lisp/Pathname.java

Modified: trunk/abcl/src/org/armedbear/lisp/Pathname.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Pathname.java	Tue May 24 05:24:46 2011	(r13290)
+++ trunk/abcl/src/org/armedbear/lisp/Pathname.java	Tue May 24 05:25:05 2011	(r13291)
@@ -1876,15 +1876,32 @@
         } else {
             result.type = d.type;
         }
-        if (pathname.version != NIL) {
-            result.version = pathname.version;
-        } else if (pathname.name instanceof AbstractString) {
+        //  CLHS Function MERGE-PATHNAMES 
+        //  "If no version is supplied, default-version is used. If
+        //  default-version is nil, the version component will remain
+        //  unchanged."
+        if (p.version == NIL && defaultVersion != NIL) {
             result.version = defaultVersion;
-        } else if (defaultPathname.version != NIL) {
+        } else if (p.version == NIL && defaultVersion == NIL) {
+            result.version = p.version;
+        // "If pathname does not specify a name, then the version, if
+        //  not provided, will come from default-pathname, just like
+        //  the other components. If pathname does specify a name,
+        //  then the version is not affected by default-pathname. If
+        //  this process leaves the version missing, the
+        //  default-version is used."
+        } else if (p.name == NIL && p.version == NIL) {
             result.version = defaultPathname.version;
+        } else if (p.name != NIL) {
+            if (defaultVersion != NIL) {
+                result.version = defaultVersion;
+            } else {
+                result.version = p.version;
+            }
         } else {
-            result.version = defaultVersion;
+            result.version = defaultPathname.version;
         }
+
         if (pathname instanceof LogicalPathname) {
             // When we're returning a logical
             result.device = Keyword.UNSPECIFIC;




More information about the armedbear-cvs mailing list