Changeset 15413
- Timestamp:
- 10/14/20 07:07:23 (3 years ago)
- Location:
- trunk/abcl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/JarPathname.java
r15412 r15413 551 551 return result; 552 552 } 553 554 static LispObject makeDeviceFrom(JarPathname p) {555 JarPathname result = new JarPathname();556 result.copyFrom(p);557 Pathname rootJar = (Pathname)result.getRootJar();558 if (!rootJar.equals(NIL)559 && (rootJar instanceof Pathname)) {560 rootJar = (Pathname)URLPathname.createFromFile(rootJar);561 result.setDevice(new Cons(rootJar, result.getJars().cdr()));562 }563 return result;564 }565 566 static LispObject makeJarDeviceFrom(Pathname p) {567 JarPathname result = new JarPathname();568 result.copyFrom(p);569 Pathname rootJar = (Pathname)result.getRootJar();570 // Ensure571 if (!rootJar.equals(NIL)572 && (rootJar instanceof Pathname)) {573 rootJar = (Pathname)URLPathname.createFromFile(rootJar);574 result.setDevice(new Cons(rootJar, result.getJars().cdr()));575 }576 return result.getDevice();577 }578 553 } -
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r15410 r15413 172 172 Pathname copyFrom(Pathname p) { 173 173 if (p.host != NIL) { 174 if (p.host instanceof SimpleString) { 175 setHost(new SimpleString(((SimpleString)p.getHost()).getStringValue())); 176 } else if (p.host instanceof Symbol) { 177 setHost(p.host); 178 } else if (p.host instanceof Cons) { 179 host = new Cons((Cons)p.getHost()); 174 LispObject pHost = p.getHost(); 175 if (pHost instanceof SimpleString) { 176 setHost(new SimpleString(pHost.getStringValue())); 177 } else if (pHost instanceof Symbol) { 178 setHost(pHost); 179 } else if (pHost instanceof Cons) { 180 LispObject newHost = NIL; 181 LispObject components = pHost.reverse(); 182 while (!components.car().equals(NIL)) { 183 LispObject copy = components.car(); // TODO actually make a copy? 184 newHost = newHost.push(copy); 185 components = components.cdr(); 186 } 187 setHost(newHost); 180 188 } else { 181 189 simple_error("Failed to copy host in pathname ~a", p); … … 188 196 LispObject jars = p.getDevice(); 189 197 setDevice(NIL); 190 URLPathname root = URLPathname.create((Pathname)jars.car()); 198 URLPathname root = null; 199 Pathname rootPathname = (Pathname) jars.car(); 200 if (rootPathname instanceof URLPathname) { 201 root = URLPathname.create((URLPathname)rootPathname); 202 } else { 203 root = URLPathname.create((Pathname)rootPathname); 204 } 191 205 device = device.push(root); 192 206 jars = jars.cdr(); … … 1237 1251 if (p.getDevice() instanceof Cons) { 1238 1252 JarPathname result = new JarPathname(); 1239 result 1240 .copyFrom(p) 1241 .setDevice(JarPathname.makeJarDeviceFrom(p)); 1242 1253 result.copyFrom(p); 1254 Pathname root = (Pathname)result.getDevice().car(); 1255 URLPathname rootDevice = null; 1256 if (root instanceof URLPathname) { 1257 rootDevice = URLPathname.create((URLPathname)root); 1258 } else { 1259 rootDevice = URLPathname.create(root); 1260 } 1261 result.setDevice(new Cons(rootDevice, result.getDevice().cdr())); 1243 1262 // sanity check that the pathname has been constructed correctly 1263 1244 1264 result.validateComponents(); 1245 1246 1265 return result; 1247 1266 } 1248 1249 1267 return p; 1250 1268 } 1269 1251 1270 1252 1271 private static final AbstractString validateStringComponent(AbstractString s) { -
trunk/abcl/src/org/armedbear/lisp/URLPathname.java
r15409 r15413 163 163 host = host.push(FRAGMENT).push(new SimpleString(fragment)); 164 164 } 165 result.setHost(host.nreverse()); 165 host = host.nreverse(); 166 result.setHost(host); 166 167 167 168 // URI encode necessary characters -
trunk/abcl/test/src/org/armedbear/lisp/JarPathnameTest.java
r15408 r15413 78 78 "jar:jar:file:///foo.jar!/baz.abcl!/", 79 79 "jar:jar:file:///foo.jar!/baz.abcl!/__loader__._", 80 "jar:jar:jar:file:///a/b/foo.jar!/c/baz.zip!/log4j.jar!/MF/manifest.mf" 80 "jar:jar:jar:file:///a/b/foo.jar!/c/baz.zip!/log4j.jar!/MF/manifest.mf", 81 "jar:https://abcl.org/releases/1.7.1/abcl-contrib.jar!/" 81 82 }; 82 83 … … 114 115 } 115 116 } 117 118 @Test 119 public void makePathname() { 120 String urlString = "https://abcl.org/releases/1.7.1/abcl-contrib.jar"; 121 URLPathname urlPathname = URLPathname.create(urlString); 122 LispObject args[] = {Keyword.DEVICE, Lisp.list(urlPathname)}; 123 LispObject result = Symbol.MAKE_PATHNAME.execute(args); 124 assertTrue("MAKE-PATHNAME created instance of a JAR-PATHNAME", result instanceof JarPathname); 125 String expectedNamestring 126 = MessageFormat.format("jar:{0}!/", urlString); 127 String resultingNamestring 128 = ((JarPathname)result).getNamestring(); 129 assertTrue(MessageFormat.format("Namestring '{0}' is '{1}'", expectedNamestring, resultingNamestring), 130 expectedNamestring.equals(resultingNamestring)); 131 } 132 116 133 }
Note: See TracChangeset
for help on using the changeset viewer.