Changeset 12798
- Timestamp:
- 07/10/10 20:22:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r12797 r12798 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 } … … 668 642 if (name instanceof AbstractString) { 669 643 String n = name.getStringValue(); 670 if (n.indexOf( File.separatorChar) >= 0) {644 if (n.indexOf('/') >= 0) { 671 645 Debug.assertTrue(namestring == null); 672 646 return null; … … 739 713 // the namestring." 19.2.2.2.3.1 740 714 if (directory != NIL) { 741 final char separatorChar; 742 if (isJar() || isURL()) { 743 separatorChar = '/'; 744 } else { 745 separatorChar = File.separatorChar; 746 } 715 final char separatorChar = '/'; 747 716 LispObject temp = directory; 748 717 LispObject part = temp.car(); … … 792 761 String path = p.getNamestring(); 793 762 StringBuilder result = new StringBuilder(); 794 if (Utilities.isPlatformWindows) { 795 for (int i = 0; i < path.length(); i++) { 796 char c = path.charAt(i); 797 if (c == '\\') { 798 result.append('/'); 799 } else { 800 result.append(c); 801 } 802 } 803 } else { 804 result.append(path); 805 } 763 result.append(path); 764 806 765 // Entries in jar files are always relative, but Pathname 807 766 // directories are :ABSOLUTE. … … 905 864 } 906 865 } 907 } else { 866 } else { 908 867 useNamestring = false; 909 868 } … … 927 886 } 928 887 } else { 929 sb.append("#P("); 888 final boolean ANSI_COMPATIBLE = true; 889 final String separator; 890 if (ANSI_COMPATIBLE) { 891 sb.append("#P("); 892 separator = "\""; 893 } else { 894 sb.append("#P("); 895 separator = " "; 896 } 930 897 if (host != NIL) { 931 898 sb.append(":HOST "); 932 899 sb.append(host.writeToString()); 933 sb.append( ' ');900 sb.append(separator); 934 901 } 935 902 if (device != NIL) { 936 903 sb.append(":DEVICE "); 937 904 sb.append(device.writeToString()); 938 sb.append( ' ');905 sb.append(separator); 939 906 } 940 907 if (directory != NIL) { 941 908 sb.append(":DIRECTORY "); 942 909 sb.append(directory.writeToString()); 943 sb.append( " ");910 sb.append(separator); 944 911 } 945 912 if (name != NIL) { 946 913 sb.append(":NAME "); 947 914 sb.append(name.writeToString()); 948 sb.append( ' ');915 sb.append(separator); 949 916 } 950 917 if (type != NIL) { 951 918 sb.append(":TYPE "); 952 919 sb.append(type.writeToString()); 953 sb.append( ' ');920 sb.append(separator); 954 921 } 955 922 if (version != NIL) { 956 923 sb.append(":VERSION "); 957 924 sb.append(version.writeToString()); 958 sb.append( ' ');959 } 960 if (sb.charAt(sb.length() - 1) == ' ') { 925 sb.append(separator); 926 } 927 if (sb.charAt(sb.length() - 1) == ' ') { // XXX 961 928 sb.setLength(sb.length() - 1); 962 929 } 963 sb.append(')'); 930 if (ANSI_COMPATIBLE) { 931 sb.append(')' + separator); 932 } else { 933 sb.append(')'); 934 } 964 935 } 965 936 return sb.toString(); … … 1379 1350 for (int i = 0; i < limit; i++) { 1380 1351 char c = s.charAt(i); 1352 // XXX '\\' should be illegal in all Pathnames at this point? 1381 1353 if (c == '/' || c == '\\' && Utilities.isPlatformWindows) { 1382 1354 error(new LispError("Invalid character #\\" + c
Note: See TracChangeset
for help on using the changeset viewer.