Changeset 13033


Ignore:
Timestamp:
11/20/10 14:36:57 (13 years ago)
Author:
Mark Evenson
Message:

[ticket #110][backport r13024,r13026] Fix #\+ in JAR pathnames.

Location:
branches/0.23.x/abcl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/0.23.x/abcl/CHANGES

    r13003 r13033  
    1616Fixes
    1717-----
     18
     19* [ticket #110][svn r13024,r13026] Fix #\+ in JAR pathnames does not work
    1820
    1921* [svn r12995-12997] Changes to generated byte code to prevent JRockit JVM
  • branches/0.23.x/abcl/src/org/armedbear/lisp/Pathname.java

    r13006 r13033  
    197197    public Pathname(URL url) {
    198198        if ("file".equals(url.getProtocol())) {
    199             String s;
    200             try {
    201                 s = URLDecoder.decode(url.getPath(), "UTF-8");
    202             } catch (java.io.UnsupportedEncodingException uee) {
    203                 // Can't happen: every Java is supposed to support
    204                 // at least UTF-8 encoding
    205                 Debug.assertTrue(false);
    206                 s = null;
    207             }
     199            String s = url.getPath();
    208200            if (s != null) {
    209     if (Utilities.isPlatformWindows) {
    210         //  Workaround for Java's idea of URLs
    211         //  new (URL"file:///c:/a/b").getPath() --> "/c:/a/b"
     201                if (Utilities.isPlatformWindows) {
     202                    //  Workaround for Java's idea of URLs
     203                    //  new (URL"file:///c:/a/b").getPath() --> "/c:/a/b"
    212204                    //  whereas we need "c" to be the DEVICE.
    213         if (s.length() > 2
    214       && s.charAt(0) == '/'
    215       && s.charAt(2) == ':') {
    216       s = s.substring(1);
    217         }
    218     }
     205                    if (s.length() > 2
     206                        && s.charAt(0) == '/'
     207                        && s.charAt(2) == ':') {
     208                        s = s.substring(1);
     209                    }
     210                }
    219211                init(s);
    220212                return;
     
    652644            if (type instanceof AbstractString) {
    653645                String t = type.getStringValue();
    654     // Allow Windows shortcuts to include TYPE
    655     if (!(t.endsWith(".lnk") && Utilities.isPlatformWindows)) {
    656         if (t.indexOf('.') >= 0) {
    657       Debug.assertTrue(namestring == null);
    658       return null;
    659         }
    660     }
     646                // Allow Windows shortcuts to include TYPE
     647                if (!(t.endsWith(".lnk") && Utilities.isPlatformWindows)) {
     648                    if (t.indexOf('.') >= 0) {
     649                        Debug.assertTrue(namestring == null);
     650                        return null;
     651                    }
     652                }
    661653                sb.append(t);
    662654            } else if (type == Keyword.WILD) {
     
    20942086            } else {
    20952087                ZipEntry entry = jarFile.getEntry(entryPath);
    2096     if (entry == null) {
    2097         Debug.trace("Failed to get InputStream for "   
    2098         + "'" + getNamestring() + "'");
     2088                if (entry == null) {
     2089                    Debug.trace("Failed to get InputStream for "   
     2090                                + "'" + getNamestring() + "'");
    20992091                    // XXX should this be fatal?
    2100         Debug.assertTrue(false);
    2101     }
     2092                    Debug.assertTrue(false);
     2093                }
    21022094                try {
    21032095                    result = jarFile.getInputStream(entry);
     
    22682260                if (Utilities.isPlatformWindows) {
    22692261                    if (destination.isFile()) {
    2270       ZipCache.remove(destination);
     2262                        ZipCache.remove(destination);
    22712263                        destination.delete();
    22722264                    }
     
    23282320
    23292321    public URL toURL() throws MalformedURLException {
    2330   if(isURL()) {
    2331       return new URL(getNamestring());
    2332   } else {
    2333       return toFile().toURL();
    2334   }
     2322        if(isURL()) {
     2323            return new URL(getNamestring());
     2324        } else {
     2325            return toFile().toURL();
     2326        }
    23352327    }
    23362328
    23372329    public File toFile() {
    2338   if(!isURL()) {
    2339       return new File(getNamestring());
    2340   } else {
    2341       throw new RuntimeException(this + " does not represent a file");
    2342   }
     2330        if(!isURL()) {
     2331            return new File(getNamestring());
     2332        } else {
     2333            throw new RuntimeException(this + " does not represent a file");
     2334        }
    23432335    }
    23442336
  • branches/0.23.x/abcl/test/lisp/abcl/jar-pathname.lisp

    r12949 r13033  
    4040    (compile-file "bar.lisp")
    4141    (compile-file "eek.lisp")
    42     (let* ((dir (merge-pathnames "tmp/" *abcl-test-directory*))
    43            (sub (merge-pathnames "a/b/" dir)))
    44       (when (probe-directory dir)
    45         (delete-directory-and-files dir))
    46       (ensure-directories-exist sub)
    47       (sys:unzip (merge-pathnames "foo.abcl")
    48                  dir)
    49       (sys:unzip (merge-pathnames "foo.abcl")
    50                  sub)
     42    (let* ((tmpdir (merge-pathnames "tmp/" *abcl-test-directory*))
     43           (subdirs
     44            (mapcar (lambda (p) (merge-pathnames p tmpdir))
     45                    '("a/b/" "d/e+f/")))
     46           (sub1 (first subdirs))
     47           (sub2 (second subdirs)))
     48      (when (probe-directory tmpdir)
     49        (delete-directory-and-files tmpdir))
     50      (mapcar (lambda (p) (ensure-directories-exist p)) subdirs)
     51      (sys:unzip (merge-pathnames "foo.abcl") tmpdir)
     52      (sys:unzip (merge-pathnames "foo.abcl") sub1)
    5153      (cl-fad-copy-file (merge-pathnames "bar.abcl")
    52                  (merge-pathnames "bar.abcl" dir))
     54                        (merge-pathnames "bar.abcl" tmpdir))
    5355      (cl-fad-copy-file (merge-pathnames "bar.abcl")
    54                  (merge-pathnames "bar.abcl" sub))
     56                        (merge-pathnames "bar.abcl" sub1))
     57      (cl-fad-copy-file (merge-pathnames "bar.abcl")
     58                        (merge-pathnames "bar.abcl" sub2))
    5559      (cl-fad-copy-file (merge-pathnames "eek.lisp")
    56                  (merge-pathnames "eek.lisp" dir))
     60                        (merge-pathnames "eek.lisp" tmpdir))
    5761      (cl-fad-copy-file (merge-pathnames "eek.lisp")
    58                  (merge-pathnames "eek.lisp" sub))
     62                        (merge-pathnames "eek.lisp" sub1))
    5963      (sys:zip (merge-pathnames "baz.jar")
    60                (append
    61                 (directory (merge-pathnames "*" dir))
    62                 (directory (merge-pathnames "*" sub)))
    63                dir)
    64       (delete-directory-and-files dir)))
     64               (loop :for p :in (list tmpdir sub1 sub2)
     65                  :appending (directory (merge-pathnames "*" p)))
     66               tmpdir)
     67      #+nil (delete-directory-and-files dir)))
    6568  (setf *jar-file-init* t))
    6669
     
    122125  t)
    123126
     127(deftest jar-pathname.load.11
     128    (with-jar-file-init
     129        (load "jar:file:baz.jar!/d/e+f/bar.abcl"))
     130  t)
     131
    124132;;; wrapped in PROGN for easy disabling without a network connection
    125133;;; XXX come up with a better abstraction
     
    132140
    133141(progn
    134   (deftest jar-pathname.load.11
     142  (deftest jar-pathname.load.http.1
    135143      (load-url-relative "foo")
    136144    t)
    137145
    138   (deftest jar-pathname.load.12
     146  (deftest jar-pathname.load.http.2
    139147      (load-url-relative "bar")
    140148    t)
    141149
    142   (deftest jar-pathname.load.13
     150  (deftest jar-pathname.load.http.3
    143151      (load-url-relative "bar.abcl")
    144152    t)
    145153
    146   (deftest jar-pathname.load.14
     154  (deftest jar-pathname.load.http.4
    147155      (load-url-relative "eek")
    148156    t)
    149157
    150   (deftest jar-pathname.load.15
     158  (deftest jar-pathname.load.http.5
    151159      (load-url-relative "eek.lisp")
    152160    t)
    153161
    154   (deftest jar-pathname.load.16
     162  (deftest jar-pathname.load.http.6
    155163      (load-url-relative "a/b/foo")
    156164    t)
    157165
    158   (deftest jar-pathname.load.17
     166  (deftest jar-pathname.load.http.7
    159167      (load-url-relative "a/b/bar")
    160168    t)
    161169
    162   (deftest jar-pathname.load.18
     170  (deftest jar-pathname.load.http.8
    163171      (load-url-relative "a/b/bar.abcl")
    164172    t)
    165173
    166   (deftest jar-pathname.load.19
     174  (deftest jar-pathname.load.http.9
    167175      (load-url-relative "a/b/eek")
    168176    t)
    169177
    170   (deftest jar-pathname.load.20
     178  (deftest jar-pathname.load.http.10
    171179      (load-url-relative "a/b/eek.lisp")
    172180    t))
     
    193201    (with-jar-file-init
    194202        (probe-file "jar:file:baz.jar!/a/b"))
    195   nil)
     203  #p#.(format nil "jar:file:~Abaz.jar!/a/b/"
     204                       (namestring *abcl-test-directory*)))
    196205
    197206(deftest jar-pathname.probe-file.5
     
    199208        (probe-file "jar:file:baz.jar!/a/b/"))
    200209  #p#.(format nil "jar:file:~Abaz.jar!/a/b/"
     210                       (namestring *abcl-test-directory*)))
     211
     212(deftest jar-pathname.probe-file.6
     213    (with-jar-file-init
     214        (probe-file "jar:file:baz.jar!/d/e+f/bar.abcl"))
     215  #p#.(format nil "jar:file:~Abaz.jar!/d/e+f/bar.abcl"
    201216                       (namestring *abcl-test-directory*)))
    202217
     
    327342  (:absolute "c" "d") "foo" "lisp")
    328343
     344(deftest jar-pathname.10
     345    (let ((s "jar:file:/foo/bar/a space/that!/this"))
     346      (equal s
     347             (namestring (pathname s))))
     348  t)
     349
     350(deftest jar-pathname.11
     351    (let ((s "jar:file:/foo/bar/a+space/that!/this"))
     352      (equal s
     353             (namestring (pathname s))))
     354  t)
     355
     356
    329357(deftest jar-pathname.match-p.1
    330358    (pathname-match-p "jar:file:/a/b/some.jar!/a/system/def.asd"
  • branches/0.23.x/abcl/test/lisp/abcl/pathname-tests.lisp

    r13011 r13033  
    439439  t)
    440440
     441#+windows
     442(deftest pathname.windows.6
     443   (equal (pathname-device #p"z:/foo/bar") "z")
     444  t)
     445
     446#+windows
     447(deftest pathname.windows.7
     448    (equal (pathname-device #p"file:z:/foo/bar") "z")
     449  t)
     450
     451#+windows
     452(deftest pathname.windows.8
     453    (equal (pathname-device #p"zoo:/foo/bar") nil)
     454  t)
     455
    441456(deftest wild.1
    442457  (check-physical-pathname #p"foo.*" nil "foo" :wild)
Note: See TracChangeset for help on using the changeset viewer.