Changeset 15460


Ignore:
Timestamp:
10/29/20 16:55:04 (2 years ago)
Author:
Mark Evenson
Message:

Address points in review from @rec

<https://github.com/armedbear/abcl/pull/335#pullrequestreview-518434813>

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

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

    r15457 r15460  
    346346    if (!(jars instanceof Cons)) {
    347347      type_error("JAR-PATHNAME device is not a cons",
    348                  jars,
    349                  Symbol.CONS);
     348                 jars, Symbol.CONS);
    350349      return (LispObject)UNREACHED;
    351350    }
     
    374373    p.copyFrom(pathname);
    375374
    376     // Run a truename resolution on the path of local jar archives
     375    // Run truename resolution on the path of local jar archives
    377376    if (p.isLocalFile()) {
    378377      Pathname rootJar;
     
    396395  return Pathname.doTruenameExit(rootJar, errorIfDoesNotExist);
    397396      }
    398       LispObject otherJars
    399         = p.getJars().cdr();
     397      LispObject otherJars = p.getJars().cdr();
    400398      URLPathname newRootJar;
    401399      if (rootJarTruename instanceof Pathname) {
     
    425423  public boolean isLocalFile() {
    426424    Pathname p = (Pathname) getRootJar();
    427     if (p.isLocalFile()) {
    428       return true;
     425    if (p != null) {
     426      return p.isLocalFile();
    429427    }
    430428    return false;
  • trunk/abcl/src/org/armedbear/lisp/ZipCache.java

    r15452 r15460  
    422422    if (innerJars.equals(NIL)) {
    423423      return getArchiveFile(jar);
    424     } else {
    425       result = getArchiveStreamFromFile(jar);
    426       cache.put(result.root, result);
    427 
    428       JarPathname nextArchive = new JarPathname();
    429       nextArchive
    430         .setDevice(new Cons(rootJar,
    431                             new Cons(innerJars.car(), NIL)))
    432         .setDirectory(NIL)
    433         .setName(NIL)
    434         .setType(NIL);
     424    }
     425
     426    result = getArchiveStreamFromFile(jar);
     427    cache.put(result.root, result);
     428
     429    JarPathname nextArchive = new JarPathname();
     430    nextArchive
     431      .setDevice(new Cons(rootJar,
     432                          new Cons(innerJars.car(), NIL)))
     433      .setDirectory(NIL)
     434      .setName(NIL)
     435      .setType(NIL);
    435436     
     437    innerJars = innerJars.cdr();
     438    while (innerJars.car() != NIL) {
     439      Pathname nextJarArchive = (Pathname)innerJars.car();
     440     
     441      JarPathname nextAsEntry = new JarPathname();
     442      nextAsEntry
     443        .setDevice(nextArchive.getDevice())
     444        .setDirectory(nextJarArchive.getDirectory())
     445        .setName(nextJarArchive.getName())
     446        .setType(nextJarArchive.getType());
     447      // FIXME
     448      // The pathnames for subsquent entries in a PATHNAME-JAR
     449      // are relative.  Should they be?
     450      LispObject directories = nextAsEntry.getDirectory();
     451      if ( !directories.equals(NIL)
     452           && directories.car().equals(Keyword.RELATIVE)) {
     453        directories = directories.cdr().push(Keyword.ABSOLUTE);
     454        nextAsEntry.setDirectory(directories);
     455      }
     456
     457      nextArchive.setDevice(nextArchive.getDevice().reverse().push(nextJarArchive).reverse());
     458      ArchiveStream stream = (ArchiveStream) result;
     459
     460      ZipEntry entry = stream.getEntry(nextAsEntry);
     461      if (entry == null) {
     462        return null;
     463      }
     464     
     465      InputStream inputStream = stream.getEntryAsInputStream(nextAsEntry);
     466      if (inputStream == null) {
     467        return null;
     468      }
     469      stream = new ArchiveStream(inputStream, nextArchive, entry);
     470      result = stream;
     471      cache.put(nextArchive, result);
     472
    436473      innerJars = innerJars.cdr();
    437       while (innerJars.car() != NIL) {
    438         Pathname nextJarArchive = (Pathname)innerJars.car();
    439 
    440         JarPathname nextAsEntry = new JarPathname();
    441         nextAsEntry
    442           .setDevice(nextArchive.getDevice())
    443           .setDirectory(nextJarArchive.getDirectory())
    444           .setName(nextJarArchive.getName())
    445           .setType(nextJarArchive.getType());
    446         // FIXME
    447         // The pathnames for subsquent entries in a PATHNAME-JAR are relative.  Should they be?
    448         if (nextAsEntry.getDirectory().car().equals(Keyword.RELATIVE)) {
    449           LispObject directories = nextAsEntry.getDirectory();
    450           directories = directories.cdr();
    451           directories = directories.push(Keyword.ABSOLUTE);
    452           nextAsEntry.setDirectory(directories);
    453         }
    454         nextArchive.setDevice(nextArchive.getDevice().reverse().push(nextJarArchive).reverse());
    455         ArchiveStream stream = (ArchiveStream) result;
    456 
    457         ZipEntry entry = stream.getEntry(nextAsEntry);
    458         if (entry == null) {
    459           return null;
    460         }
    461        
    462         InputStream inputStream = stream.getEntryAsInputStream(nextAsEntry);
    463         if (inputStream == null) {
    464           return null;
    465         }
    466         stream = new ArchiveStream(inputStream, nextArchive, entry);
    467         result = stream;
    468         cache.put(nextArchive, result);
    469 
    470         innerJars = innerJars.cdr();
    471         if (innerJars.cdr().equals(NIL)
    472             && (!jar.getDirectory().equals(NIL)
    473                 || !jar.getName().equals(NIL)
    474                 || !jar.getType().equals(NIL))) {
    475           simple_error("Currently unimplemented retrieval of an entry in a nested pathnames");
    476           return (Archive)UNREACHED;
    477         }
    478       }
    479 
    480       return result;
    481     }
     474      if (innerJars.cdr().equals(NIL)
     475          && (!jar.getDirectory().equals(NIL)
     476              && jar.getName().equals(NIL)
     477              && jar.getType().equals(NIL))) {
     478        simple_error("Currently unimplemented retrieval of an entry in a nested pathnames");
     479        return (Archive)UNREACHED;
     480      }
     481    }
     482    return result;
    482483  }
    483484
Note: See TracChangeset for help on using the changeset viewer.