[armedbear-cvs] r12802 - trunk/abcl/src/org/armedbear/lisp
Mark Evenson
mevenson at common-lisp.net
Mon Jul 12 09:51:20 UTC 2010
Author: mevenson
Date: Mon Jul 12 05:51:19 2010
New Revision: 12802
Log:
Re-apply grovel tags patch.
Modified:
trunk/abcl/src/org/armedbear/lisp/JavaClassLoader.java
trunk/abcl/src/org/armedbear/lisp/Pathname.java
trunk/abcl/src/org/armedbear/lisp/ShellCommand.java
Modified: trunk/abcl/src/org/armedbear/lisp/JavaClassLoader.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/JavaClassLoader.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/JavaClassLoader.java Mon Jul 12 05:51:19 2010
@@ -150,6 +150,7 @@
}
};
+ // ### make-classloader &optional parent => java-class-loader
private static final Primitive MAKE_CLASSLOADER = new pf_make_classloader();
private static final class pf_make_classloader extends Primitive
{
@@ -169,6 +170,7 @@
}
};
+ // ### dump-classpath &optional classloader => list-of-pathname-lists
private static final Primitive DUMP_CLASSPATH = new pf_dump_classpath();
private static final class pf_dump_classpath extends Primitive
{
@@ -195,6 +197,7 @@
}
};
+ // ### add-to-classpath jar-or-jars &optional (classloader (get-current-classloader))
private static final Primitive ADD_TO_CLASSPATH = new pf_add_to_classpath();
private static final class pf_add_to_classpath extends Primitive
{
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 Mon Jul 12 05:51:19 2010
@@ -61,7 +61,7 @@
// A positive integer, or NIL, :WILD, :UNSPECIFIC, or :NEWEST.
protected LispObject version = NIL;
- private volatile String namestring;
+ private String namestring;
/** The protocol for changing any instance field (i.e. 'host', 'type', etc.)
* is to call this method after changing the field to recompute the namestring.
@@ -242,7 +242,7 @@
return;
}
if (Utilities.isPlatformWindows) {
- if (s.startsWith("\\\\")) { // XXX What if string starts with '//'?
+ if (s.startsWith("\\\\")) {
//UNC path support
// match \\<server>\<share>\[directories-and-files]
@@ -401,9 +401,24 @@
}
if (Utilities.isPlatformWindows) {
- if (s.contains("\\")) {
- s = s.replace("\\", "/");
- }
+ if (!s.contains(jarSeparator)) {
+ s = s.replace("/", "\\");
+ } else {
+ StringBuilder result = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if ( c != '/') {
+ result.append(c);
+ } else {
+ if (i != 0 && s.charAt(i-1) != '!') {
+ result.append("\\");
+ } else {
+ result.append(c);
+ }
+ }
+ }
+ s = result.toString();
+ }
}
// Expand user home directories
@@ -423,11 +438,22 @@
}
String d = null;
// Find last file separator char.
- for (int i = s.length(); i-- > 0;) {
- if (s.charAt(i) == '/') {
- d = s.substring(0, i + 1);
- s = s.substring(i + 1);
- break;
+ if (Utilities.isPlatformWindows) {
+ for (int i = s.length(); i-- > 0;) {
+ char c = s.charAt(i);
+ if (c == '/' || c == '\\') {
+ d = s.substring(0, i + 1);
+ s = s.substring(i + 1);
+ break;
+ }
+ }
+ } else {
+ for (int i = s.length(); i-- > 0;) {
+ if (s.charAt(i) == '/') {
+ d = s.substring(0, i + 1);
+ s = s.substring(i + 1);
+ break;
+ }
}
}
if (d != null) {
@@ -591,12 +617,16 @@
sb.append("//");
sb.append(authority.getStringValue());
}
- } else if (this instanceof LogicalPathname) {
+ } else {
+ if (!(this instanceof LogicalPathname)) {
+ sb.append("\\\\"); //UNC file support; if there's a host, it's a UNC path.
+ }
sb.append(host.getStringValue());
- sb.append(':');
- } else {
- // UNC paths now use unprintable representation
- return null;
+ if (this instanceof LogicalPathname) {
+ sb.append(':');
+ } else {
+ sb.append(File.separatorChar);
+ }
}
}
if (device == NIL) {
@@ -634,7 +664,7 @@
}
if (name instanceof AbstractString) {
String n = name.getStringValue();
- if (n.indexOf('/') >= 0) {
+ if (n.indexOf(File.separatorChar) >= 0) {
Debug.assertTrue(namestring == null);
return null;
}
@@ -705,7 +735,12 @@
// is, both NIL and :UNSPECIFIC cause the component not to appear in
// the namestring." 19.2.2.2.3.1
if (directory != NIL) {
- final char separatorChar = '/';
+ final char separatorChar;
+ if (isJar() || isURL()) {
+ separatorChar = '/';
+ } else {
+ separatorChar = File.separatorChar;
+ }
LispObject temp = directory;
LispObject part = temp.car();
temp = temp.cdr();
@@ -753,8 +788,18 @@
p.invalidateNamestring();
String path = p.getNamestring();
StringBuilder result = new StringBuilder();
- result.append(path);
-
+ if (Utilities.isPlatformWindows) {
+ for (int i = 0; i < path.length(); i++) {
+ char c = path.charAt(i);
+ if (c == '\\') {
+ result.append('/');
+ } else {
+ result.append(c);
+ }
+ }
+ } else {
+ result.append(path);
+ }
// Entries in jar files are always relative, but Pathname
// directories are :ABSOLUTE.
if (result.length() > 1
@@ -833,8 +878,8 @@
@Override
public String writeToString() {
final LispThread thread = LispThread.currentThread();
- final boolean printReadably = (Symbol.PRINT_READABLY.symbolValue(thread) != NIL);
- final boolean printEscape = (Symbol.PRINT_ESCAPE.symbolValue(thread) != NIL);
+ boolean printReadably = (Symbol.PRINT_READABLY.symbolValue(thread) != NIL);
+ boolean printEscape = (Symbol.PRINT_ESCAPE.symbolValue(thread) != NIL);
boolean useNamestring;
String s = null;
s = getNamestring();
@@ -856,7 +901,7 @@
}
}
}
- } else {
+ } else {
useNamestring = false;
}
StringBuilder sb = new StringBuilder();
@@ -878,58 +923,41 @@
sb.append('"');
}
} else {
- final SpecialBindingsMark mark = thread.markSpecialBindings();
- thread.bindSpecial(Symbol.PRINT_ESCAPE, T);
- try {
- final boolean ANSI_COMPATIBLE = true;
- final String SPACE = " ";
- if (ANSI_COMPATIBLE) {
- sb.append("#P(\"");
- } else {
- sb.append("#P(");
-
- }
- if (host != NIL) {
- sb.append(":HOST ");
- sb.append(host.writeToString());
- sb.append(SPACE);
- }
- if (device != NIL) {
- sb.append(":DEVICE ");
- sb.append(device.writeToString());
- sb.append(SPACE);
- }
- if (directory != NIL) {
- sb.append(":DIRECTORY ");
- sb.append(directory.writeToString());
- sb.append(SPACE);
- }
- if (name != NIL) {
- sb.append(":NAME ");
- sb.append(name.writeToString());
- sb.append(SPACE);
- }
- if (type != NIL) {
- sb.append(":TYPE ");
- sb.append(type.writeToString());
- sb.append(SPACE);
- }
- if (version != NIL) {
- sb.append(":VERSION ");
- sb.append(version.writeToString());
- sb.append(SPACE);
- }
- if (sb.charAt(sb.length() - 1) == ' ') { // XXX
- sb.setLength(sb.length() - 1);
- }
- if (ANSI_COMPATIBLE) {
- sb.append(')' + "\"");
- } else {
- sb.append(')');
- }
- } finally {
- thread.resetSpecialBindings(mark);
+ sb.append("#P(");
+ if (host != NIL) {
+ sb.append(":HOST ");
+ sb.append(host.writeToString());
+ sb.append(' ');
+ }
+ if (device != NIL) {
+ sb.append(":DEVICE ");
+ sb.append(device.writeToString());
+ sb.append(' ');
+ }
+ if (directory != NIL) {
+ sb.append(":DIRECTORY ");
+ sb.append(directory.writeToString());
+ sb.append(" ");
+ }
+ if (name != NIL) {
+ sb.append(":NAME ");
+ sb.append(name.writeToString());
+ sb.append(' ');
+ }
+ if (type != NIL) {
+ sb.append(":TYPE ");
+ sb.append(type.writeToString());
+ sb.append(' ');
+ }
+ if (version != NIL) {
+ sb.append(":VERSION ");
+ sb.append(version.writeToString());
+ sb.append(' ');
}
+ if (sb.charAt(sb.length() - 1) == ' ') {
+ sb.setLength(sb.length() - 1);
+ }
+ sb.append(')');
}
return sb.toString();
}
@@ -1205,7 +1233,7 @@
namestring = file.getCanonicalPath();
} catch (IOException e) {
Debug.trace("Failed to make a Pathname from "
- + "." + file + "'");
+ + "'" + file + "'");
return null;
}
return new Pathname(namestring);
@@ -1274,22 +1302,17 @@
}
final Pathname p;
final boolean logical;
- LispObject logicalHost = NIL;
if (host != NIL) {
if (host instanceof AbstractString) {
- logicalHost = LogicalPathname.canonicalizeStringComponent((AbstractString) host);
- }
- if (LOGICAL_PATHNAME_TRANSLATIONS.get(logicalHost) == null) {
- // Not a defined logical pathname host -- A UNC path
- //warning(new LispError(host.writeToString() + " is not defined as a logical pathname host."));
- p = new Pathname();
- logical = false;
- p.host = host;
- } else {
- p = new LogicalPathname();
- logical = true;
- p.host = logicalHost;
+ host = LogicalPathname.canonicalizeStringComponent((AbstractString) host);
}
+ if (LOGICAL_PATHNAME_TRANSLATIONS.get(host) == null) {
+ // Not a defined logical pathname host.
+ error(new LispError(host.writeToString() + " is not defined as a logical pathname host."));
+ }
+ p = new LogicalPathname();
+ logical = true;
+ p.host = host;
p.device = Keyword.UNSPECIFIC;
} else {
p = new Pathname();
@@ -1352,7 +1375,6 @@
final int limit = s.length();
for (int i = 0; i < limit; i++) {
char c = s.charAt(i);
- // XXX '\\' should be illegal in all Pathnames at this point?
if (c == '/' || c == '\\' && Utilities.isPlatformWindows) {
error(new LispError("Invalid character #\\" + c
+ " in pathname component \"" + s
Modified: trunk/abcl/src/org/armedbear/lisp/ShellCommand.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ShellCommand.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/ShellCommand.java Mon Jul 12 05:51:19 2010
@@ -235,13 +235,9 @@
// run-shell-command command &key directory (output *standard-output*)
// ### %run-shell-command command directory output => exit-code
- private static final Primitive _RUN_SHELL_COMMAND = new pf_run_shell_command();
- private static class pf_run_shell_command extends Primitive {
- pf_run_shell_command() {
- super("%run-shell-command", PACKAGE_SYS, false,
- "command directory output => exit-code");
- }
-
+ private static final Primitive _RUN_SHELL_COMMAND =
+ new Primitive("%run-shell-command", PACKAGE_SYS, false)
+ {
@Override
public LispObject execute(LispObject first, LispObject second,
LispObject third)
More information about the armedbear-cvs
mailing list