Changeset 13291


Ignore:
Timestamp:
05/24/11 12:25:05 (10 years ago)
Author:
Mark Evenson
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Pathname.java

    r13288 r13291  
    18771877            result.type = d.type;
    18781878        }
    1879         if (pathname.version != NIL) {
    1880             result.version = pathname.version;
    1881         } else if (pathname.name instanceof AbstractString) {
     1879        //  CLHS Function MERGE-PATHNAMES
     1880        //  "If no version is supplied, default-version is used. If
     1881        //  default-version is nil, the version component will remain
     1882        //  unchanged."
     1883        if (p.version == NIL && defaultVersion != NIL) {
    18821884            result.version = defaultVersion;
    1883         } else if (defaultPathname.version != NIL) {
     1885        } else if (p.version == NIL && defaultVersion == NIL) {
     1886            result.version = p.version;
     1887        // "If pathname does not specify a name, then the version, if
     1888        //  not provided, will come from default-pathname, just like
     1889        //  the other components. If pathname does specify a name,
     1890        //  then the version is not affected by default-pathname. If
     1891        //  this process leaves the version missing, the
     1892        //  default-version is used."
     1893        } else if (p.name == NIL && p.version == NIL) {
    18841894            result.version = defaultPathname.version;
     1895        } else if (p.name != NIL) {
     1896            if (defaultVersion != NIL) {
     1897                result.version = defaultVersion;
     1898            } else {
     1899                result.version = p.version;
     1900            }
    18851901        } else {
    1886             result.version = defaultVersion;
    1887         }
     1902            result.version = defaultPathname.version;
     1903        }
     1904
    18881905        if (pathname instanceof LogicalPathname) {
    18891906            // When we're returning a logical
Note: See TracChangeset for help on using the changeset viewer.