Changeset 14238


Ignore:
Timestamp:
11/09/12 16:07:08 (8 years ago)
Author:
Mark Evenson
Message:

Fixes #243: MAKE-PATHNAME with a DEVICE string.

We allow DEVICE lists to contain a string value as constructed by
MAKE-PATHNAME, but the result can never actually be resolvable by
TRUENAME.

Instead of trying to figure out the proper use of Java labels, just
use the private static Pathname.doTruenameExit() as the common point
for all exits from the TRUENAME implementation.

Location:
trunk/abcl
Files:
2 edited

Legend:

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

    r14178 r14238  
    655655            for (int i = 0; i < jars.length; i++) {
    656656                prefix.append("jar:");
    657                 if (!((Pathname)jars[i]).isURL() && i == 0) {
     657    LispObject component = jars[i];
     658    if (!(component instanceof Pathname)) {
     659       return null; // If DEVICE is a CONS, it should only contain Pathname
     660    }
     661                if (! ((Pathname)component).isURL() && i == 0) {
    658662                    sb.append("file:");
    659663                    uriEncoded = true;
    660664                }
    661                 Pathname jar = (Pathname) jars[i];
     665                Pathname jar = (Pathname) component;
    662666                String encodedNamestring;
    663667                if (uriEncoded) {
     
    21532157                                            boolean errorIfDoesNotExist)
    21542158    {
    2155         if (pathname == null || pathname.equals(NIL)) {  // XXX duplicates code at the end of this longish function: figure out proper nesting of labels.
    2156             if (errorIfDoesNotExist) {
    2157                 StringBuilder sb = new StringBuilder("The file ");
    2158                 sb.append(pathname.princToString());
    2159                 sb.append(" does not exist.");
    2160                 return error(new FileError(sb.toString(), pathname));
    2161             }
    2162             return NIL;
     2159        if (pathname == null || pathname.equals(NIL)) { 
     2160           return doTruenameExit(pathname, errorIfDoesNotExist);
    21632161        }
    21642162        if (pathname instanceof LogicalPathname) {
     
    22102208            Cons jars = (Cons) pathname.device;
    22112209            LispObject o = jars.car();
     2210      if (!(o instanceof Pathname)) {
     2211         return doTruenameExit(pathname, errorIfDoesNotExist);
     2212      }
    22122213            if (o instanceof Pathname
    22132214                && !(((Pathname)o).isURL())
     
    22872288        }
    22882289        error:
     2290    return doTruenameExit(pathname, errorIfDoesNotExist);
     2291    }
     2292   
     2293    static private LispObject doTruenameExit(Pathname pathname, boolean errorIfDoesNotExist) {
    22892294        if (errorIfDoesNotExist) {
    22902295            StringBuilder sb = new StringBuilder("The file ");
  • trunk/abcl/test/lisp/abcl/bugs.lisp

    r13940 r14238  
    112112  3)
    113113     
     114;;; http://trac.common-lisp.net/armedbear/ticket/243
     115(deftest bugs.pathname.make-pathname.1
     116    (signals-error
     117     (make-pathname :device (list "foo"))
     118     'error)
     119t)
     120
     121
     122(deftest bugs.pathname.make-pathname.2
     123  (probe-file (make-pathname :device (list "foo")))
     124nil)
Note: See TracChangeset for help on using the changeset viewer.