Changeset 12531


Ignore:
Timestamp:
03/14/10 13:30:17 (11 years ago)
Author:
Mark Evenson
Message:

Change jar pathname to have :ABSOLUTE directory entries.

As pointed out by Alan Ruttenburg and Alessio Stalla, having :RELATIVE
directory entries is contrary to the semantics of the CLHS and
violates the convention common in Common Lisp that the TRUENAME of a
pathname directory will be absolute.

Location:
trunk/abcl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/doc/design/pathnames/abcl-jar-url.text

    r12523 r12531  
    33
    44Mark Evenson
    5 Created: 09 JAN 2010
    6 Modified: 22 FEB 2010
     5Created:  09 JAN 2010
     6Modified: 16 MAR 2010
    77
    88Notes towards sketching an implementation of "jar:" references to be
     
    9191   
    9292*   The DIRECTORY component of a JAR PATHNAME should be a list starting
    93     with the :RELATIVE keyword, as hierarchial entries in jar files
    94     are of the form "foo/bar/a.lisp" not "/foo/bar/a.lisp"
     93    with the :ABSOLUTE keyword.  Even though hierarchial entries in
     94    jar files are stored in the form "foo/bar/a.lisp" not
     95    "/foo/bar/a.lisp", the meaning of DIRECTORY component better
     96    represented as an absolute path.
    9597
    9698BNF
     
    109111                     | RELATIVE-FILE-NAMESTRING
    110112
    111   ENTRY ::= [ DIRECTORY "/"] * FILE
     113  ENTRY ::= [ DIRECTORY "/"]* FILE
    112114
    113115
     
    175177    }
    176178    pathname {
    177       directory: (:RELATIVE "b")
     179      directory: (:RELATIVE "b" "c")
    178180      name: "foo"
    179181      type: "abcl"
     
    187189// UC5 -- JAR Entry in a JAR Entry
    188190pathname: {
    189   namestring: "jar:jar:file:a/foo/baz.jar!/foo.abcl!/a/b/bar-1.cls"
     191  namestring: "jar:jar:file:a/foo/baz.jar!/c/d/foo.abcl!/a/b/bar-1.cls"
    190192  device: (
    191193    pathname: {
    192       device: "jar:file:"
     194      directory: (:RELATIVE "a" "foo")
    193195      name: "baz"
    194196      type: "jar"
    195197    }
    196198    pathname: {
     199      directory: (:RELATIVE "c" "d")
    197200      name: "foo"
    198201      type: "abcl"
    199202    }
    200203  )
     204  directory: (:ABSOLUTE "a" "b")
    201205  name: "bar-1"
    202206  type: "cls"
     
    209213    "http://example.org/abcl.jar"
    210214    pathname: {
    211       directory: (:relative "org" "armedbear" "lisp")
     215      directory: (:RELATIVE "org" "armedbear" "lisp")
    212216      name: "Version"
    213217      type: "class"
     
    250254     type: "jar"
    251255   )
    252    directory: (:RELATIVE "c" "d")
     256   directory: (:ABSOLUTE "c" "d")
    253257   name: "foo"
    254258   type: "lisp
  • trunk/abcl/src/org/armedbear/lisp/Pathname.java

    r12524 r12531  
    297297                device = d.device;
    298298            }
    299             s = s.substring(separatorIndex + jarSeparator.length());
     299            s = "/" + s.substring(separatorIndex + jarSeparator.length());
    300300            Pathname p = new Pathname(s);
    301301            directory = p.directory;
     
    533533            Debug.assertTrue(false);
    534534        }
    535         sb.append(getDirectoryNamestring());
     535        String directoryNamestring = getDirectoryNamestring();
     536        if (isJar()) {
     537            if (directoryNamestring.startsWith(File.separator)) {
     538                sb.append(directoryNamestring.substring(1));
     539            }
     540        } else {
     541            sb.append(directoryNamestring);
     542        }
    536543        if (name instanceof AbstractString) {
    537544            String n = name.getStringValue();
     
    636643        p.type = type;
    637644        String path = p.getNamestring();
     645        StringBuilder result = new StringBuilder();
    638646        if (Utilities.isPlatformWindows) {
    639       StringBuilder result = new StringBuilder();
    640647      for (int i = 0; i < path.length(); i++) {
    641648    char c = path.charAt(i);
     
    647654      }
    648655      return result.toString();
    649         }
    650         return path;
     656        } else  {
     657            result.append(path);
     658        }
     659        // Entries in jar files are always relative, but Pathname
     660        // directories are :ABSOLUTE.
     661        if (result.length() > 1
     662          && result.substring(0, 1).equals("/")) {
     663            return result.substring(1);
     664        }
     665        return result.toString();
    651666    }
    652667
     
    15901605        }
    15911606
    1592         // A JAR always has relative directories
    1593         if (result.isJar()
    1594             && result.directory instanceof Cons
    1595             && result.directory.car().equals(Keyword.ABSOLUTE)) {
    1596             if (result.directory.cdr().equals(NIL)) {
    1597                 result.directory = NIL;
    1598             } else {
    1599                 ((Cons)result.directory).car = Keyword.RELATIVE;
    1600             }
    1601         }
     1607        // A JAR always has absolute directories
     1608        // if (result.isJar()
     1609        //     && result.directory instanceof Cons
     1610        //     && result.directory.car().equals(Keyword.ABSOLUTE)) {
     1611        //     if (result.directory.cdr().equals(NIL)) {
     1612        //         result.directory = NIL;
     1613        //     } else {
     1614        //         ((Cons)result.directory).car = Keyword.RELATIVE;
     1615        //     }
     1616        // }
    16021617
    16031618        if (pathname.name != NIL) {
     
    17081723        if (pathname.isWild()) {
    17091724            return error(new FileError("Bad place for a wild pathname.",
    1710               pathname));
     1725                                       pathname));
    17111726        }
    17121727        if (!(pathname.device instanceof Cons)) {
  • trunk/abcl/src/org/armedbear/lisp/ZipCache.java

    r12504 r12531  
    160160                Date date = null;
    161161                try {
     162                    if (dateString == null) {
     163                        throw new ParseException("Failed to get HEAD for " + url, 0);
     164                    }
    162165                    date = RFC_1123.parse(dateString);
    163166                    long current = date.getTime();
  • trunk/abcl/test/lisp/abcl/jar-file.lisp

    r12486 r12531  
    131131;;; wrapped in PROGN for easy disabling without a network connection
    132132;;; XXX come up with a better abstraction
     133
    133134(progn
    134135  (deftest jar-file.load.11
     
    245246       (pathname-directory p) (pathname-name p) (pathname-type p)))
    246247  "baz" "jar"
    247    nil "foo" "abcl")
     248   (:absolute) "foo" "abcl")
    248249   
    249250(deftest jar-file.pathname.3
     
    267268  (:relative "a") "baz" "jar"
    268269  (:relative "b" "c") "foo" "abcl"
    269   (:relative "this" "that") "foo-20" "cls")
     270  (:absolute "this" "that") "foo-20" "cls")
    270271
    271272(deftest jar-file.pathname.5
     
    279280  (:relative "a" "foo" ) "baz" "jar"
    280281  (:relative "b" "c") "foo" "abcl"
    281   (:relative "armed" "bear") "bar-1" "cls")
     282  (:absolute "armed" "bear") "bar-1" "cls")
    282283
    283284(deftest jar-file.pathname.6
     
    289290       (pathname-directory p) (pathname-name p) (pathname-type p)))
    290291  "http://example.org/abcl.jar"
    291   (:relative "org" "armedbear" "lisp") "Version" "class")
     292  (:absolute "org" "armedbear" "lisp") "Version" "class")
    292293
    293294(deftest jar-file.pathname.7
     
    317318       (pathname-directory d) (pathname-name d) (pathname-type d)
    318319       (pathname-directory p) (pathname-name p) (pathname-type p)))
    319   (:RELATIVE "a" "b") "foo" "jar"
    320   (:RELATIVE "c" "d") "foo" "lisp")
     320  (:relative "a" "b") "foo" "jar"
     321  (:absolute "c" "d") "foo" "lisp")
    321322
    322323     
Note: See TracChangeset for help on using the changeset viewer.