[armedbear-cvs] r12531 - in trunk/abcl: doc/design/pathnames src/org/armedbear/lisp test/lisp/abcl

Mark Evenson mevenson at common-lisp.net
Sun Mar 14 13:30:21 UTC 2010


Author: mevenson
Date: Sun Mar 14 09:30:17 2010
New Revision: 12531

Log:
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.



Modified:
   trunk/abcl/doc/design/pathnames/abcl-jar-url.text
   trunk/abcl/src/org/armedbear/lisp/Pathname.java
   trunk/abcl/src/org/armedbear/lisp/ZipCache.java
   trunk/abcl/test/lisp/abcl/jar-file.lisp

Modified: trunk/abcl/doc/design/pathnames/abcl-jar-url.text
==============================================================================
--- trunk/abcl/doc/design/pathnames/abcl-jar-url.text	(original)
+++ trunk/abcl/doc/design/pathnames/abcl-jar-url.text	Sun Mar 14 09:30:17 2010
@@ -2,8 +2,8 @@
 ============================
 
 Mark Evenson
-Created: 09 JAN 2010
-Modified: 22 FEB 2010
+Created:  09 JAN 2010
+Modified: 16 MAR 2010 
 
 Notes towards sketching an implementation of "jar:" references to be
 contained in PATHNAMEs within ABCL.  
@@ -90,8 +90,10 @@
     innermost.
     
 *   The DIRECTORY component of a JAR PATHNAME should be a list starting
-    with the :RELATIVE keyword, as hierarchial entries in jar files
-    are of the form "foo/bar/a.lisp" not "/foo/bar/a.lisp"
+    with the :ABSOLUTE keyword.  Even though hierarchial entries in
+    jar files are stored in the form "foo/bar/a.lisp" not
+    "/foo/bar/a.lisp", the meaning of DIRECTORY component better
+    represented as an absolute path.
 
 BNF
 ---
@@ -108,7 +110,7 @@
   JAR-NAMESTRING  ::=  ABSOLUTE-FILE-NAMESTRING
                      | RELATIVE-FILE-NAMESTRING
 
-  ENTRY ::= [ DIRECTORY "/"] * FILE
+  ENTRY ::= [ DIRECTORY "/"]* FILE
 
 
 ### Notes
@@ -174,7 +176,7 @@
       type: "jar"
     }
     pathname {
-      directory: (:RELATIVE "b")
+      directory: (:RELATIVE "b" "c")
       name: "foo"
       type: "abcl"
     }
@@ -186,18 +188,20 @@
 
 // UC5 -- JAR Entry in a JAR Entry
 pathname: {
-  namestring: "jar:jar:file:a/foo/baz.jar!/foo.abcl!/a/b/bar-1.cls"
+  namestring: "jar:jar:file:a/foo/baz.jar!/c/d/foo.abcl!/a/b/bar-1.cls"
   device: (
     pathname: {
-      device: "jar:file:"
+      directory: (:RELATIVE "a" "foo")
       name: "baz"
       type: "jar"
     }
     pathname: {
+      directory: (:RELATIVE "c" "d")
       name: "foo"
       type: "abcl"
     }
   )
+  directory: (:ABSOLUTE "a" "b")
   name: "bar-1"
   type: "cls"
 }
@@ -208,7 +212,7 @@
   device: ( 
     "http://example.org/abcl.jar"
     pathname: {
-      directory: (:relative "org" "armedbear" "lisp")
+      directory: (:RELATIVE "org" "armedbear" "lisp")
       name: "Version"
       type: "class"
    }
@@ -249,7 +253,7 @@
      name: "foo"
      type: "jar"
    )
-   directory: (:RELATIVE "c" "d")
+   directory: (:ABSOLUTE "c" "d")
    name: "foo"
    type: "lisp
 }

Modified: trunk/abcl/src/org/armedbear/lisp/Pathname.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Pathname.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Pathname.java	Sun Mar 14 09:30:17 2010
@@ -296,7 +296,7 @@
             } else {
                 device = d.device;
             }
-            s = s.substring(separatorIndex + jarSeparator.length());
+            s = "/" + s.substring(separatorIndex + jarSeparator.length());
             Pathname p = new Pathname(s);
             directory = p.directory;
             name = p.name;
@@ -532,7 +532,14 @@
         } else {
             Debug.assertTrue(false);
         }
-        sb.append(getDirectoryNamestring());
+        String directoryNamestring = getDirectoryNamestring();
+        if (isJar()) {
+            if (directoryNamestring.startsWith(File.separator)) {
+                sb.append(directoryNamestring.substring(1));
+            }
+        } else {
+            sb.append(directoryNamestring);
+        }
         if (name instanceof AbstractString) {
             String n = name.getStringValue();
             if (n.indexOf(File.separatorChar) >= 0) {
@@ -635,8 +642,8 @@
         p.name = name;
         p.type = type;
         String path = p.getNamestring();
+        StringBuilder result = new StringBuilder();
         if (Utilities.isPlatformWindows) {
-	    StringBuilder result = new StringBuilder();
 	    for (int i = 0; i < path.length(); i++) {
 		char c = path.charAt(i);
 		if (c == '\\') {
@@ -646,8 +653,16 @@
 		}
 	    }
 	    return result.toString();
+        } else  {
+            result.append(path);
         }
-        return path;
+        // Entries in jar files are always relative, but Pathname
+        // directories are :ABSOLUTE.
+        if (result.length() > 1
+          && result.substring(0, 1).equals("/")) {
+            return result.substring(1);
+        }
+        return result.toString();
     }
 
     @Override
@@ -1589,16 +1604,16 @@
             result.directory = mergeDirectories(p.directory, d.directory);
         }
 
-        // A JAR always has relative directories
-        if (result.isJar()
-            && result.directory instanceof Cons
-            && result.directory.car().equals(Keyword.ABSOLUTE)) {
-            if (result.directory.cdr().equals(NIL)) {
-                result.directory = NIL;
-            } else {
-                ((Cons)result.directory).car = Keyword.RELATIVE;
-            }
-        }
+        // A JAR always has absolute directories
+        // if (result.isJar()
+        //     && result.directory instanceof Cons
+        //     && result.directory.car().equals(Keyword.ABSOLUTE)) {
+        //     if (result.directory.cdr().equals(NIL)) {
+        //         result.directory = NIL;
+        //     } else {
+        //         ((Cons)result.directory).car = Keyword.RELATIVE;
+        //     }
+        // }
 
         if (pathname.name != NIL) {
             result.name = p.name;
@@ -1707,7 +1722,7 @@
         }
         if (pathname.isWild()) {
             return error(new FileError("Bad place for a wild pathname.",
-              pathname));
+                                       pathname));
         }
         if (!(pathname.device instanceof Cons)) {
             pathname

Modified: trunk/abcl/src/org/armedbear/lisp/ZipCache.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ZipCache.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ZipCache.java	Sun Mar 14 09:30:17 2010
@@ -159,6 +159,9 @@
                 String dateString = HttpHead.get(url, "Last-Modified");
                 Date date = null;
                 try {
+                    if (dateString == null) {
+                        throw new ParseException("Failed to get HEAD for " + url, 0);
+                    }
                     date = RFC_1123.parse(dateString);
                     long current = date.getTime();
                     if (current > entry.lastModified) {

Modified: trunk/abcl/test/lisp/abcl/jar-file.lisp
==============================================================================
--- trunk/abcl/test/lisp/abcl/jar-file.lisp	(original)
+++ trunk/abcl/test/lisp/abcl/jar-file.lisp	Sun Mar 14 09:30:17 2010
@@ -130,6 +130,7 @@
 
 ;;; wrapped in PROGN for easy disabling without a network connection
 ;;; XXX come up with a better abstraction
+
 (progn 
   (deftest jar-file.load.11
       (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/foo")
@@ -244,7 +245,7 @@
        (pathname-name d) (pathname-type d) 
        (pathname-directory p) (pathname-name p) (pathname-type p)))
   "baz" "jar"
-   nil "foo" "abcl")
+   (:absolute) "foo" "abcl")
    
 (deftest jar-file.pathname.3
     (let* ((p #p"jar:jar:file:baz.jar!/foo.abcl!/")
@@ -266,7 +267,7 @@
        (pathname-directory p) (pathname-name p) (pathname-type p)))
   (:relative "a") "baz" "jar"
   (:relative "b" "c") "foo" "abcl"
-  (:relative "this" "that") "foo-20" "cls")
+  (:absolute "this" "that") "foo-20" "cls")
 
 (deftest jar-file.pathname.5
     (let* ((p #p"jar:jar:file:a/foo/baz.jar!/b/c/foo.abcl!/armed/bear/bar-1.cls")
@@ -278,7 +279,7 @@
        (pathname-directory p) (pathname-name p) (pathname-type p)))
   (:relative "a" "foo" ) "baz" "jar"
   (:relative "b" "c") "foo" "abcl"
-  (:relative "armed" "bear") "bar-1" "cls")
+  (:absolute "armed" "bear") "bar-1" "cls")
 
 (deftest jar-file.pathname.6
     (let* ((p #p"jar:http://example.org/abcl.jar!/org/armedbear/lisp/Version.class")
@@ -288,7 +289,7 @@
        d
        (pathname-directory p) (pathname-name p) (pathname-type p)))
   "http://example.org/abcl.jar" 
-  (:relative "org" "armedbear" "lisp") "Version" "class")
+  (:absolute "org" "armedbear" "lisp") "Version" "class")
 
 (deftest jar-file.pathname.7
     (let* ((p #p"jar:jar:http://example.org/abcl.jar!/foo.abcl!/foo-1.cls")
@@ -316,8 +317,8 @@
       (values
        (pathname-directory d) (pathname-name d) (pathname-type d)
        (pathname-directory p) (pathname-name p) (pathname-type p)))
-  (:RELATIVE "a" "b") "foo" "jar"
-  (:RELATIVE "c" "d") "foo" "lisp")
+  (:relative "a" "b") "foo" "jar"
+  (:absolute "c" "d") "foo" "lisp")
 
       
       




More information about the armedbear-cvs mailing list