Changeset 12803
- Timestamp:
- 07/12/10 09:55:11 (13 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r12802 r12803 62 62 protected LispObject version = NIL; 63 63 64 private String namestring;64 private volatile String namestring; 65 65 66 66 /** The protocol for changing any instance field (i.e. 'host', 'type', etc.) … … 243 243 } 244 244 if (Utilities.isPlatformWindows) { 245 if (s.startsWith("\\\\")) { 245 if (s.startsWith("\\\\")) { // XXX What if string starts with '//'? 246 246 //UNC path support 247 247 // match \\<server>\<share>\[directories-and-files] … … 402 402 403 403 if (Utilities.isPlatformWindows) { 404 if (!s.contains(jarSeparator)) { 405 s = s.replace("/", "\\"); 406 } else { 407 StringBuilder result = new StringBuilder(); 408 for (int i = 0; i < s.length(); i++) { 409 char c = s.charAt(i); 410 if ( c != '/') { 411 result.append(c); 412 } else { 413 if (i != 0 && s.charAt(i-1) != '!') { 414 result.append("\\"); 415 } else { 416 result.append(c); 417 } 418 } 419 } 420 s = result.toString(); 421 } 404 if (s.contains("\\")) { 405 s = s.replace("\\", "/"); 406 } 422 407 } 423 408 … … 439 424 String d = null; 440 425 // Find last file separator char. 441 if (Utilities.isPlatformWindows) { 442 for (int i = s.length(); i-- > 0;) { 443 char c = s.charAt(i); 444 if (c == '/' || c == '\\') { 445 d = s.substring(0, i + 1); 446 s = s.substring(i + 1); 447 break; 448 } 449 } 450 } else { 451 for (int i = s.length(); i-- > 0;) { 452 if (s.charAt(i) == '/') { 453 d = s.substring(0, i + 1); 454 s = s.substring(i + 1); 455 break; 456 } 426 for (int i = s.length(); i-- > 0;) { 427 if (s.charAt(i) == '/') { 428 d = s.substring(0, i + 1); 429 s = s.substring(i + 1); 430 break; 457 431 } 458 432 } … … 618 592 sb.append(authority.getStringValue()); 619 593 } 620 } else { 621 if (!(this instanceof LogicalPathname)) { 622 sb.append("\\\\"); //UNC file support; if there's a host, it's a UNC path. 623 } 594 } else if (this instanceof LogicalPathname) { 624 595 sb.append(host.getStringValue()); 625 if (this instanceof LogicalPathname) { 626 sb.append(':'); 627 } else { 628 sb.append(File.separatorChar); 629 } 596 sb.append(':'); 597 } else { 598 // UNC paths now use unprintable representation 599 return null; 630 600 } 631 601 } … … 665 635 if (name instanceof AbstractString) { 666 636 String n = name.getStringValue(); 667 if (n.indexOf( File.separatorChar) >= 0) {637 if (n.indexOf('/') >= 0) { 668 638 Debug.assertTrue(namestring == null); 669 639 return null; … … 736 706 // the namestring." 19.2.2.2.3.1 737 707 if (directory != NIL) { 738 final char separatorChar; 739 if (isJar() || isURL()) { 740 separatorChar = '/'; 741 } else { 742 separatorChar = File.separatorChar; 743 } 708 final char separatorChar = '/'; 744 709 LispObject temp = directory; 745 710 LispObject part = temp.car(); … … 789 754 String path = p.getNamestring(); 790 755 StringBuilder result = new StringBuilder(); 791 if (Utilities.isPlatformWindows) { 792 for (int i = 0; i < path.length(); i++) { 793 char c = path.charAt(i); 794 if (c == '\\') { 795 result.append('/'); 796 } else { 797 result.append(c); 798 } 799 } 800 } else { 801 result.append(path); 802 } 756 result.append(path); 757 803 758 // Entries in jar files are always relative, but Pathname 804 759 // directories are :ABSOLUTE. … … 879 834 public String writeToString() { 880 835 final LispThread thread = LispThread.currentThread(); 881 boolean printReadably = (Symbol.PRINT_READABLY.symbolValue(thread) != NIL);882 boolean printEscape = (Symbol.PRINT_ESCAPE.symbolValue(thread) != NIL);836 final boolean printReadably = (Symbol.PRINT_READABLY.symbolValue(thread) != NIL); 837 final boolean printEscape = (Symbol.PRINT_ESCAPE.symbolValue(thread) != NIL); 883 838 boolean useNamestring; 884 839 String s = null; … … 902 857 } 903 858 } 904 } else { 859 } else { 905 860 useNamestring = false; 906 861 } … … 924 879 } 925 880 } else { 926 sb.append("#P("); 927 if (host != NIL) { 928 sb.append(":HOST "); 929 sb.append(host.writeToString()); 930 sb.append(' '); 931 } 932 if (device != NIL) { 933 sb.append(":DEVICE "); 934 sb.append(device.writeToString()); 935 sb.append(' '); 936 } 937 if (directory != NIL) { 938 sb.append(":DIRECTORY "); 939 sb.append(directory.writeToString()); 940 sb.append(" "); 941 } 942 if (name != NIL) { 943 sb.append(":NAME "); 944 sb.append(name.writeToString()); 945 sb.append(' '); 946 } 947 if (type != NIL) { 948 sb.append(":TYPE "); 949 sb.append(type.writeToString()); 950 sb.append(' '); 951 } 952 if (version != NIL) { 953 sb.append(":VERSION "); 954 sb.append(version.writeToString()); 955 sb.append(' '); 956 } 957 if (sb.charAt(sb.length() - 1) == ' ') { 958 sb.setLength(sb.length() - 1); 959 } 960 sb.append(')'); 881 final SpecialBindingsMark mark = thread.markSpecialBindings(); 882 thread.bindSpecial(Symbol.PRINT_ESCAPE, T); 883 try { 884 final boolean ANSI_COMPATIBLE = true; 885 final String SPACE = " "; 886 if (ANSI_COMPATIBLE) { 887 sb.append("#P(\""); 888 } else { 889 sb.append("#P("); 890 891 } 892 if (host != NIL) { 893 sb.append(":HOST "); 894 sb.append(host.writeToString()); 895 sb.append(SPACE); 896 } 897 if (device != NIL) { 898 sb.append(":DEVICE "); 899 sb.append(device.writeToString()); 900 sb.append(SPACE); 901 } 902 if (directory != NIL) { 903 sb.append(":DIRECTORY "); 904 sb.append(directory.writeToString()); 905 sb.append(SPACE); 906 } 907 if (name != NIL) { 908 sb.append(":NAME "); 909 sb.append(name.writeToString()); 910 sb.append(SPACE); 911 } 912 if (type != NIL) { 913 sb.append(":TYPE "); 914 sb.append(type.writeToString()); 915 sb.append(SPACE); 916 } 917 if (version != NIL) { 918 sb.append(":VERSION "); 919 sb.append(version.writeToString()); 920 sb.append(SPACE); 921 } 922 if (sb.charAt(sb.length() - 1) == ' ') { // XXX 923 sb.setLength(sb.length() - 1); 924 } 925 if (ANSI_COMPATIBLE) { 926 sb.append(')' + "\""); 927 } else { 928 sb.append(')'); 929 } 930 } finally { 931 thread.resetSpecialBindings(mark); 932 } 961 933 } 962 934 return sb.toString(); … … 1234 1206 } catch (IOException e) { 1235 1207 Debug.trace("Failed to make a Pathname from " 1236 + " '" + file + "'");1208 + "." + file + "'"); 1237 1209 return null; 1238 1210 } … … 1303 1275 final Pathname p; 1304 1276 final boolean logical; 1277 LispObject logicalHost = NIL; 1305 1278 if (host != NIL) { 1306 1279 if (host instanceof AbstractString) { 1307 host = LogicalPathname.canonicalizeStringComponent((AbstractString) host); 1308 } 1309 if (LOGICAL_PATHNAME_TRANSLATIONS.get(host) == null) { 1310 // Not a defined logical pathname host. 1311 error(new LispError(host.writeToString() + " is not defined as a logical pathname host.")); 1312 } 1313 p = new LogicalPathname(); 1314 logical = true; 1315 p.host = host; 1280 logicalHost = LogicalPathname.canonicalizeStringComponent((AbstractString) host); 1281 } 1282 if (LOGICAL_PATHNAME_TRANSLATIONS.get(logicalHost) == null) { 1283 // Not a defined logical pathname host -- A UNC path 1284 //warning(new LispError(host.writeToString() + " is not defined as a logical pathname host.")); 1285 p = new Pathname(); 1286 logical = false; 1287 p.host = host; 1288 } else { 1289 p = new LogicalPathname(); 1290 logical = true; 1291 p.host = logicalHost; 1292 } 1316 1293 p.device = Keyword.UNSPECIFIC; 1317 1294 } else { … … 1376 1353 for (int i = 0; i < limit; i++) { 1377 1354 char c = s.charAt(i); 1355 // XXX '\\' should be illegal in all Pathnames at this point? 1378 1356 if (c == '/' || c == '\\' && Utilities.isPlatformWindows) { 1379 1357 error(new LispError("Invalid character #\\" + c -
trunk/abcl/src/org/armedbear/lisp/ShellCommand.java
r12802 r12803 236 236 // run-shell-command command &key directory (output *standard-output*) 237 237 // ### %run-shell-command command directory output => exit-code 238 private static final Primitive _RUN_SHELL_COMMAND = 239 new Primitive("%run-shell-command", PACKAGE_SYS, false) 240 { 238 private static final Primitive _RUN_SHELL_COMMAND = new pf_run_shell_command(); 239 private static class pf_run_shell_command extends Primitive { 240 pf_run_shell_command() { 241 super("%run-shell-command", PACKAGE_SYS, false, 242 "command directory output => exit-code"); 243 } 244 241 245 @Override 242 246 public LispObject execute(LispObject first, LispObject second,
Note: See TracChangeset
for help on using the changeset viewer.