Changeset 15404


Ignore:
Timestamp:
10/10/20 21:43:42 (3 years ago)
Author:
Mark Evenson
Message:

Remove unused methods, extraneous comments

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

Legend:

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

    r15403 r15404  
    753753        sb.append("PATHNAME (with no namestring) ");
    754754        if (getHost() != NIL) {
    755             sb.append(":HOST ");
    756             sb.append(getHost().printObject());
    757             sb.append(" ");
     755            sb.append(":HOST ")
     756              .append(getHost().printObject())
     757              .append(" ");
    758758        }
    759759        if (getDevice() != NIL) {
    760             sb.append(":DEVICE ");
    761             sb.append(getDevice().printObject());
    762             sb.append(" ");
     760            sb.append(":DEVICE ")
     761              .append(getDevice().printObject())
     762              .append(" ");
    763763        }
    764764        if (getDirectory() != NIL) {
    765             sb.append(":DIRECTORY ");
    766             sb.append(getDirectory().printObject());
    767             sb.append(" ");
     765            sb.append(":DIRECTORY ")
     766              .append(getDirectory().printObject())
     767              .append(" ");
    768768        }
    769769        if (getName() != NIL) {
    770             sb.append(":NAME ");
    771             sb.append(getName().printObject());
    772             sb.append(" ");
     770            sb.append(":NAME ")
     771              .append(getName().printObject())
     772              .append(" ");
    773773        }
    774774        if (getType() != NIL) {
    775             sb.append(":TYPE ");
    776             sb.append(getType().printObject());
    777             sb.append(" ");
     775            sb.append(":TYPE ")
     776              .append(getType().printObject())
     777              .append(" ");
    778778        }
    779779        if (getVersion() != NIL) {
    780             sb.append(":VERSION ");
    781             sb.append(getVersion().printObject());
    782             sb.append(" ");
     780            sb.append(":VERSION ")
     781              .append(getVersion().printObject())
     782              .append(" ");
    783783        }
    784784        if (sb.charAt(sb.length() - 1) == ' ') {
  • trunk/abcl/src/org/armedbear/lisp/PathnameJar.java

    r15401 r15404  
    6868  public static LispObject createFromPathname(Pathname p) {
    6969    if (p instanceof PathnameURL) {
    70       return PathnameJar.create(JAR_URI_PREFIX + ((PathnameURL)p).getNamestringAsURI() + JAR_URI_SUFFIX);
     70      return PathnameJar.create(JAR_URI_PREFIX
     71                                + ((PathnameURL)p).getNamestringAsURI()
     72                                + JAR_URI_SUFFIX);
    7173    } else if (p instanceof Pathname) {
    7274      // FIXME: not going to work with namestrings with characters that need URI escaping
    73       return PathnameJar.create(JAR_URI_PREFIX + "file://" + p.getNamestring() + JAR_URI_SUFFIX);
     75      return PathnameJar.create(JAR_URI_PREFIX
     76                                + "file://" + p.getNamestring()
     77                                + JAR_URI_SUFFIX);
    7478    } else {
    7579      return p;
     
    155159  }
    156160
    157   // FIXME: badly named
    158   static PathnameJar createJarPathname(String ns) {
    159     PathnameJar result = new PathnameJar();
    160     if (ns.length() == 0) { // ??? what calls in this state?
    161       return result;
    162     }
    163 
    164     PathnameURL p;
    165    
    166     URL url = null;
    167     URI uri = null;
    168 
    169     String nsURL = ns;
    170     if (!Pathname.isValidURL(nsURL)) {
    171       nsURL = "file:" + nsURL;
    172     }
    173    
    174     try {
    175       url = new URL(nsURL);
    176       uri = url.toURI();
    177     } catch (MalformedURLException e1) {
    178       parse_error("Failed to create URI from " + "'" + nsURL + "'" + ": " + e1.getMessage());
    179       return null;
    180     } catch (URISyntaxException e2) {
    181       parse_error("Failed to create URI from " + "'" + nsURL + "'" + ": " + e2.getMessage());
    182       return null;
    183     }
    184 
    185     String path = uri.getPath();
    186     String pathAsURI;
    187     if (path == null) {
    188       // We allow "jar:file:baz.jar!/" to construct a relative
    189       // path for jar files, so MERGE-PATHNAMES means something.
    190       pathAsURI = "file:" + uri.getSchemeSpecificPart();
    191     } else {
    192       // FIXME:  Windows drive letters???
    193       String pathFromFile = (new File(path)).getPath();
    194       pathAsURI = "file:" + pathFromFile;
    195     }
    196        
    197     p = (PathnameURL)PathnameURL.create(pathAsURI);
    198     Pathname.ncoerce(p, result);
    199    
    200     return result;
    201   }
    202 
    203161  static public LispObject create(String s) {
    204162    if (!s.startsWith(JAR_URI_PREFIX)) {
     
    230188        Pathname pathname = (Pathname)Pathname.create(nsWithoutSuffix);
    231189        Pathname jar = new Pathname();
    232         Pathname.ncoerce(pathname, jar);
     190        jar.copyFrom(pathname);
    233191        jars = jars.push(jar);
    234192      } else {
    235193        Pathname p = (Pathname)Pathname.create(contents.get(i));
    236         Pathname.ncoerce(p, result);
     194        result.copyFrom(p);
    237195      }
    238196    }
     
    271229
    272230    if (jars.equals(NIL) || jars.equals(Keyword.UNSPECIFIC)) {
    273         System.out.println("Pathname transitional problem: JAR-PATHNAME has bad PATHNAME-DEVICE");
    274         return null;
     231      type_error("JAR-PATHNAME has bad DEVICE",
     232                 jars,
     233                 list(Symbol.NOT,
     234                      list(Symbol.OR,
     235                           list(Symbol.EQL, NIL),
     236                           list(Symbol.EQL, Keyword.UNSPECIFIC))));
     237      return (String)UNREACHED;
    275238    }
    276239
     
    301264        Pathname jar = (Pathname)innerJars.car();
    302265        Pathname p = new Pathname();
    303         Pathname.ncoerce(jar, p);
    304         p.setDevice(NIL);
     266        p.copyFrom(jar)
     267         .setDevice(NIL);
    305268        String ns = p.getNamestring();
    306269        sb.append(ns)
     
    332295    LispObject jars = getJars();
    333296    if (!(jars instanceof Cons)) {
    334       System.out.println("Transitional pathname error: PATHNAME-DEVICE is not a Cons cell");
    335       return NIL;
     297      type_error("JAR-PATHNAME device is not a cons",
     298                 jars,
     299                 Symbol.CONS);
     300      return (LispObject)UNREACHED;
    336301    }
    337302     
     
    591556  }
    592557}
    593      
    594 
    595     // String rootJarNamestring = ((Pathname)rootJar).getNamestring();
    596     // try {
    597     //   ZipFile jarFile = new ZipFile(rootJarNamestring);
    598     //   ZipFileInputStream inputStream = null;
    599     //   while (enclosingJars.car() != NIL) {
    600     //     LispObject jar = enclosingJars.car();
    601     //     String ns = ((Pathname)jar).getNamestring();
    602     //     ZipEntry entry = currentZip.getEntry(ns);
    603     //     if (entry == null) {
    604     //       return simple_error("Failed to find entry ~a in ~a", ns, pathname);
    605     //     }
    606     //     InputStream i = entry.getInputStream();
    607     //     ZipInputStream zi = new ZipInputStream(i);
    608     //     enclosingJars = enclosingJars.cdr();
    609     //   }
    610     // } catch (IOException e) {
    611     //   return Pathname.doTruenameExit(result, errorIfDoesNotExist);
    612     // }
    613 
    614 
    615 
    616 
    617 
    618   // truename
    619   //   jarfile: {
    620         //     // Possibly canonicalize jar file directory
    621         //     LispObject o = pathname.getDevice();
    622         //     if (!(o instanceof Pathname)) {
    623         //       return doTruenameExit(pathname, errorIfDoesNotExist);
    624         //     }
    625         //     if (o instanceof Pathname
    626         //         && !(((Pathname)o).isURL())
    627         //         // XXX Silently fail to call truename() if the default
    628         //         // pathname defaults exist within a jar, as that will
    629         //         // (probably) not succeed.  The better solution would
    630         //         // probably be to parametize the value of
    631         //         // *DEFAULT-PATHNAME-DEFAULTS* on invocations of
    632         //         // truename().
    633         //         && !coerceToPathname(Symbol.DEFAULT_PATHNAME_DEFAULTS.symbolValue()).isJar())
    634         //       {
    635         //         LispObject truename = Pathname.truename((Pathname)o, errorIfDoesNotExist);
    636         //         if (truename != null && truename != NIL
    637         //             && truename instanceof Pathname) {
    638         //             Pathname truePathname = (Pathname)truename;
    639         //             // A jar that is a directory makes no sense, so exit
    640         //             if (truePathname.getNamestring().endsWith("/")) {
    641         //                 break jarfile;
    642         //             }
    643         //             jars.car = truePathname;
    644         //         } else {
    645         //             break jarfile;
    646         //         }
    647         //       }
    648 
    649         //     // Check for existence of a JAR file and/or JarEntry
    650         //     //
    651         //     // Cases:
    652         //     // 1.  JAR
    653         //     // 2.  JAR in JAR
    654         //     // 3.  JAR with Entry
    655         //     // 4.  JAR in JAR with Entry
    656 
    657         //     ZipFile jarFile = ZipCache.get((Pathname)jars.car());
    658         //     String entryPath = pathname.asEntryPath();
    659         //     if (jarFile != null) {
    660         //         if (jars.cdr() instanceof Cons) {
    661         //           Pathname inner = (Pathname) jars.cdr().car();
    662         //           InputStream inputStream = Utilities.getInputStream(jarFile, inner);
    663         //           if (inputStream != null) {
    664         //               if (entryPath.length() == 0) {
    665         //                   return pathname; // Case 2
    666         //               } else {
    667         //                   ZipInputStream zipInputStream
    668         //                       = new ZipInputStream(inputStream);
    669         //                   ZipEntry entry = Utilities.getEntry(zipInputStream,
    670         //                                                       entryPath,
    671         //                                                       false);
    672         //                   if (entry != null) {
    673         //                       // XXX this could possibly be a directory?
    674         //                       return pathname; // Case 4
    675         //                  }
    676         //               }
    677         //           }
    678         //         } else {
    679         //             if (entryPath.length() == 0) {
    680         //                 return pathname; // Case 1
    681         //             } else {
    682         //                 ZipEntry entry = jarFile.getEntry(entryPath);
    683         //                 if (entry != null) {
    684         //                     // ensure this isn't a directory
    685         //                     if (entry.isDirectory()) {
    686         //                         break jarfile;
    687         //                     }
    688         //                     try {
    689         //                         InputStream input = jarFile.getInputStream(entry);
    690         //                         if (input != null) {
    691         //                             return pathname; // Case 3
    692         //                         }
    693         //                     } catch (IOException e) {
    694         //                         break jarfile;
    695         //                     }
    696         //                 }
    697         //             }
    698         //         }
    699         //     }
    700         // }
    701 
    702 
    703 
    704 
    705 // Pathname.init()
    706           // A JAR file
    707 
    708 
    709             // LispObject jars = NIL;
    710             // int i = s.lastIndexOf(jarSeparator, s.length() - jarSeparator.length() - 1);
    711             // String jar = null;
    712             // if (i == -1) {
    713             //     jar = s;
    714             // } else {
    715             //     // There can be no more than two jar references and the
    716             //     // inner one must be a file reference within the outer.
    717             //     jar = "jar:file:" + s.substring(i + jarSeparator.length());
    718             //     s = s.substring("jar:".length(), i + jarSeparator.length());
    719             //     Pathname p = (Pathname) Pathname.create(s);
    720             //     jars = jars.push(p.getDevice().car());
    721             // }
    722             // if (jar.startsWith("jar:file:")) { // PathnameJar should handle this part

    723             //     String file
    724             //         = jar.substring("jar:file:".length(),
    725             //                         jar.length() - jarSeparator.length());
    726             //     Pathname jarPathname;
    727             //     if (file.length() > 0) {
    728             //         URL url = null;
    729             //         URI uri = null;
    730             //         try {
    731             //             url = new URL("file:" + file);
    732             //             uri = url.toURI();
    733             //         } catch (MalformedURLException e1) {
    734             //             error(new SimpleError("Failed to create URI from "
    735             //                                 + "'" + file + "'"
    736             //                                 + ": " + e1.getMessage()));
    737             //         } catch (URISyntaxException e2) {
    738             //             error(new SimpleError("Failed to create URI from "
    739             //                                 + "'" + file + "'"
    740             //                                 + ": " + e2.getMessage()));
    741             //         }
    742             //         String path = uri.getPath();
    743             //         if (path == null) {
    744             //             // We allow "jar:file:baz.jar!/" to construct a relative
    745             //             // path for jar files, so MERGE-PATHNAMES means something.
    746             //           jarPathname = (Pathname)Pathname.create(uri.getSchemeSpecificPart());
    747             //         } else {
    748             //           jarPathname = (Pathname)Pathname.create((new File(path)).getPath());
    749             //         }
    750             //     } else {
    751             //       jarPathname = (Pathname)Pathname.create("");
    752             //     }
    753             //     jars = jars.push(jarPathname);
    754             // } else {
    755             //     URL url = null;
    756             //     try {
    757             //         url = new URL(jar.substring("jar:".length(), jar.length() - 2));
    758             //         Pathname p = (Pathname)Pathname.create(url);
    759             //         jars = jars.push(p);
    760             //     } catch (MalformedURLException e) {
    761             //         error(new LispError("Failed to parse URL "
    762             //                             + "'" + url + "'"
    763             //                             + e.getMessage()));
    764             //     }
    765             // }
    766             // jars = jars.nreverse();
    767             // setDevice(jars);
    768             // invalidateNamestring();
    769             // return;
    770 
    771 
    772         // // An entry in a JAR file
    773         // final int separatorIndex = s.lastIndexOf(jarSeparator);
    774         // if (separatorIndex > 0 && s.startsWith("jar:")) {
    775         //   return PathnameJar.create(s);
    776         // }
    777         //     final String jarURL = s.substring(0, separatorIndex + jarSeparator.length());
    778         //     URL url = null;
    779         //     try {
    780         //         url = new URL(jarURL);
    781         //     } catch (MalformedURLException ex) {
    782         //         error(new LispError("Failed to parse URL "
    783         //                             + "'" + jarURL + "'"
    784         //                             + ex.getMessage()));
    785         //     }
    786         //     Pathname d = (Pathname)Pathname.create(url);
    787         //     if (getDevice() instanceof Cons) {
    788         //         LispObject[] jars = d.copyToArray();
    789         //         //  XXX Is this ever reached?  If so, need to append lists
    790         //         Debug.assertTrue(false);
    791         //     } else {
    792         //         setDevice(d.getDevice());
    793         //     }
    794         //     s = "/" + s.substring(separatorIndex + jarSeparator.length());
    795         //     Pathname p = (Pathname)Pathname.create("file:" + s); // Use URI escaping rules
    796         //     setDirectory(p.getDirectory());
    797         //     setName(p.getName());
    798         //     setType(p.getType());
    799         //     setVersion(p.getVersion());
    800         //     return;
    801         // }
    802 
    803 
    804 
    805 
  • trunk/abcl/src/org/armedbear/lisp/PathnameURL.java

    r15401 r15404  
    190190    // Use the output of Pathname
    191191    Pathname p = new Pathname();
    192     p.copyFrom(this);
    193     Pathname.ncoerce(this, p);
    194     p.setHost(NIL);
    195     p.setDevice(NIL);
    196     p.setDirectory(NIL);
     192    p.copyFrom(this)
     193      .setHost(NIL)
     194      .setDevice(NIL)
     195      .setDirectory(NIL);
    197196    String nameTypeVersion = p.getNamestring();
    198197    sb.append(nameTypeVersion);
     
    200199    LispObject o = Symbol.GETF.execute(getHost(), QUERY, NIL);
    201200    if (o != NIL) {
    202       sb.append("?");
    203       sb.append(o.getStringValue());
     201      sb.append("?")
     202        .append(o.getStringValue());
    204203    }
    205204    o = Symbol.GETF.execute(getHost(), FRAGMENT, NIL);
    206205    if (o != NIL) {
    207       sb.append("#");
    208       sb.append(o.getStringValue());
    209     }
    210 
    211     //namestring = sb.toString();
     206      sb.append("#")
     207        .append(o.getStringValue());
     208    }
     209
    212210    return sb.toString();
    213211  }
     
    316314  }
    317315
    318 
    319316  public long getLastModified() {
    320317    return getURLConnection().getLastModified();
    321318  }
    322319
    323     @DocString(name="uri-decode",
     320  @DocString(name="uri-decode",
    324321             args="string",
    325322             returns="string",
    326   doc="Decode STRING percent escape sequences in the manner of URI encodings.")
     323             doc="Decode STRING percent escape sequences in the manner of URI encodings.")
    327324  private static final Primitive URI_DECODE = new pf_uri_decode();
    328325  private static final class pf_uri_decode extends Primitive {
     
    351348             args="string",
    352349             returns="string",
    353   doc="Encode percent escape sequences in the manner of URI encodings.")
     350             doc="Encode percent escape sequences in the manner of URI encodings.")
    354351  private static final Primitive URI_ENCODE = new pf_uri_encode();
    355352  private static final class pf_uri_encode extends Primitive {
Note: See TracChangeset for help on using the changeset viewer.