Changeset 12486
- Timestamp:
- 02/20/10 11:27:07 (12 years ago)
- Location:
- trunk/abcl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r12485 r12486 365 365 directory = parseDirectory(d); 366 366 } 367 if (s.startsWith(".") && s.indexOf(".", 1) == -1) { 367 if (s.startsWith(".") 368 // No TYPE can be parsed 369 && (s.indexOf(".", 1) == -1 370 || s.substring(s.length() -1).equals("."))) { 368 371 name = new SimpleString(s); 369 372 return; … … 859 862 } 860 863 // ### %pathname-host 861 private static final Primitive _PATHNAME_HOST = new _pathname_host();862 private static class _pathname_host extends Primitive {863 _pathname_host() {864 private static final Primitive _PATHNAME_HOST = new pf_pathname_host(); 865 private static class pf_pathname_host extends Primitive { 866 pf_pathname_host() { 864 867 super("%pathname-host", PACKAGE_SYS, false); 865 868 } … … 871 874 } 872 875 // ### %pathname-device 873 private static final Primitive _PATHNAME_DEVICE = new _pathname_device();874 private static class _pathname_device extends Primitive {875 _pathname_device() {876 private static final Primitive _PATHNAME_DEVICE = new pf_pathname_device(); 877 private static class pf_pathname_device extends Primitive { 878 pf_pathname_device() { 876 879 super("%pathname-device", PACKAGE_SYS, false); 877 880 } … … 883 886 } 884 887 // ### %pathname-directory 885 private static final Primitive _PATHNAME_DIRECTORY = new _pathname_directory();886 private static class _pathname_directory extends Primitive {887 _pathname_directory() {888 private static final Primitive _PATHNAME_DIRECTORY = new pf_pathname_directory(); 889 private static class pf_pathname_directory extends Primitive { 890 pf_pathname_directory() { 888 891 super("%pathname-directory", PACKAGE_SYS, false); 889 892 } … … 895 898 } 896 899 // ### %pathname-name 897 private static final Primitive _PATHNAME_NAME = new _pathname_name();898 private static class _pathname_name extends Primitive {899 _pathname_name() {900 private static final Primitive _PATHNAME_NAME = new pf_pathname_name(); 901 private static class pf_pathname_name extends Primitive { 902 pf_pathname_name() { 900 903 super ("%pathname-name", PACKAGE_SYS, false); 901 904 } … … 907 910 } 908 911 // ### %pathname-type 909 private static final Primitive _PATHNAME_TYPE = new _pathname_type();910 private static class _pathname_type extends Primitive {911 _pathname_type() {912 private static final Primitive _PATHNAME_TYPE = new pf_pathname_type(); 913 private static class pf_pathname_type extends Primitive { 914 pf_pathname_type() { 912 915 super("%pathname-type", PACKAGE_SYS, false); 913 916 } … … 919 922 } 920 923 // ### pathname-version 921 private static final Primitive PATHNAME_VERSION = new p athname_version();922 private static class p athname_version extends Primitive {923 p athname_version() {924 private static final Primitive PATHNAME_VERSION = new pf_pathname_version(); 925 private static class pf_pathname_version extends Primitive { 926 pf_pathname_version() { 924 927 super("pathname-version", "pathname"); 925 928 } … … 931 934 // ### namestring 932 935 // namestring pathname => namestring 933 private static final Primitive NAMESTRING = new namestring();934 private static class namestring extends Primitive {935 namestring() {936 private static final Primitive NAMESTRING = new pf_namestring(); 937 private static class pf_namestring extends Primitive { 938 pf_namestring() { 936 939 super("namestring", "pathname"); 937 940 } … … 949 952 // ### directory-namestring 950 953 // directory-namestring pathname => namestring 951 private static final Primitive DIRECTORY_NAMESTRING = new directory_namestring();952 private static class directory_namestring extends Primitive {953 directory_namestring() {954 private static final Primitive DIRECTORY_NAMESTRING = new pf_directory_namestring(); 955 private static class pf_directory_namestring extends Primitive { 956 pf_directory_namestring() { 954 957 super("directory-namestring", "pathname"); 955 958 } … … 960 963 } 961 964 // ### pathname pathspec => pathname 962 private static final Primitive PATHNAME = new p athname();963 private static class p athname extends Primitive {964 p athname() {965 private static final Primitive PATHNAME = new pf_pathname(); 966 private static class pf_pathname extends Primitive { 967 pf_pathname() { 965 968 super("pathname", "pathspec"); 966 969 } … … 971 974 } 972 975 // ### %parse-namestring string host default-pathname => pathname, position 973 private static final Primitive _PARSE_NAMESTRING = new _parse_namestring();974 private static class _parse_namestring extends Primitive {975 _parse_namestring() {976 private static final Primitive _PARSE_NAMESTRING = new pf_parse_namestring(); 977 private static class pf_parse_namestring extends Primitive { 978 pf_parse_namestring() { 976 979 super("%parse-namestring", PACKAGE_SYS, false, 977 980 "namestring host default-pathname"); … … 1003 1006 } 1004 1007 // ### make-pathname 1005 private static final Primitive MAKE_PATHNAME = new make_pathname();1006 private static class make_pathname extends Primitive {1007 make_pathname() {1008 private static final Primitive MAKE_PATHNAME = new pf_make_pathname(); 1009 private static class pf_make_pathname extends Primitive { 1010 pf_make_pathname() { 1008 1011 super("make-pathname", 1009 1012 "&key host device directory name type version defaults case"); … … 1200 1203 } 1201 1204 // ### pathnamep 1202 private static final Primitive PATHNAMEP = new p athnamep();1203 private static class p athnamep extends Primitive {1204 p athnamep() {1205 private static final Primitive PATHNAMEP = new pf_pathnamep(); 1206 private static class pf_pathnamep extends Primitive { 1207 pf_pathnamep() { 1205 1208 super("pathnamep", "object"); 1206 1209 } … … 1211 1214 } 1212 1215 // ### logical-pathname-p 1213 private static final Primitive LOGICAL_PATHNAME_P = new logical_pathname_p();1214 private static class logical_pathname_p extends Primitive {1215 logical_pathname_p() {1216 private static final Primitive LOGICAL_PATHNAME_P = new pf_logical_pathname_p(); 1217 private static class pf_logical_pathname_p extends Primitive { 1218 pf_logical_pathname_p() { 1216 1219 super("logical-pathname-p", PACKAGE_SYS, true, "object"); 1217 1220 } … … 1222 1225 } 1223 1226 // ### user-homedir-pathname &optional host => pathname 1224 private static final Primitive USER_HOMEDIR_PATHNAME = new user_homedir_pathname();1225 private static class user_homedir_pathname extends Primitive {1226 user_homedir_pathname() {1227 private static final Primitive USER_HOMEDIR_PATHNAME = new pf_user_homedir_pathname(); 1228 private static class pf_user_homedir_pathname extends Primitive { 1229 pf_user_homedir_pathname() { 1227 1230 super("user-homedir-pathname", "&optional host"); 1228 1231 } … … 1245 1248 } 1246 1249 // ### list-directory directory 1247 private static final Primitive LIST_DIRECTORY = new list_directory();1248 private static class list_directory extends Primitive {1249 list_directory() {1250 private static final Primitive LIST_DIRECTORY = new pf_list_directory(); 1251 private static class pf_list_directory extends Primitive { 1252 pf_list_directory() { 1250 1253 super("list-directory", PACKAGE_SYS, true, "directory"); 1251 1254 } … … 1302 1305 1303 1306 // ### PATHNAME-JAR-P 1304 private static final Primitive PATHNAME_JAR_P = new p athname_jar_p();1305 private static class p athname_jar_p extends Primitive {1306 p athname_jar_p() {1307 private static final Primitive PATHNAME_JAR_P = new pf_pathname_jar_p(); 1308 private static class pf_pathname_jar_p extends Primitive { 1309 pf_pathname_jar_p() { 1307 1310 super("pathname-jar-p", PACKAGE_SYS, true, "pathname", 1308 1311 "Predicate for whether PATHNAME references a JAR."); … … 1349 1352 } 1350 1353 // ### %wild-pathname-p 1351 private static final Primitive _WILD_PATHNAME_P = 1352 new Primitive("%wild-pathname-p", PACKAGE_SYS, true) { 1353 1354 @Override 1355 public LispObject execute(LispObject first, LispObject second) { 1356 Pathname pathname = coerceToPathname(first); 1357 if (second == NIL) { 1358 return pathname.isWild() ? T : NIL; 1359 } 1360 if (second == Keyword.DIRECTORY) { 1361 if (pathname.directory instanceof Cons) { 1362 if (memq(Keyword.WILD, pathname.directory)) { 1363 return T; 1364 } 1365 if (memq(Keyword.WILD_INFERIORS, pathname.directory)) { 1366 return T; 1367 } 1368 } 1369 return NIL; 1370 } 1371 LispObject value; 1372 if (second == Keyword.HOST) { 1373 value = pathname.host; 1374 } else if (second == Keyword.DEVICE) { 1375 value = pathname.device; 1376 } else if (second == Keyword.NAME) { 1377 value = pathname.name; 1378 } else if (second == Keyword.TYPE) { 1379 value = pathname.type; 1380 } else if (second == Keyword.VERSION) { 1381 value = pathname.version; 1382 } else { 1383 return error(new ProgramError("Unrecognized keyword " 1384 + second.writeToString() + ".")); 1385 } 1386 if (value == Keyword.WILD || value == Keyword.WILD_INFERIORS) { 1387 return T; 1388 } else { 1389 return NIL; 1390 } 1391 } 1392 }; 1393 // ### merge-pathnames 1394 private static final Primitive MERGE_PATHNAMES = 1395 new Primitive("merge-pathnames", 1396 "pathname &optional default-pathname default-version") { 1397 1398 @Override 1399 public LispObject execute(LispObject arg) { 1400 Pathname pathname = coerceToPathname(arg); 1401 Pathname defaultPathname = 1354 private static final Primitive _WILD_PATHNAME_P = new pf_wild_pathname_p(); 1355 static final class pf_wild_pathname_p extends Primitive { 1356 pf_wild_pathname_p() { 1357 super("%wild-pathname-p", PACKAGE_SYS, true); 1358 } 1359 @Override 1360 public LispObject execute(LispObject first, LispObject second) { 1361 Pathname pathname = coerceToPathname(first); 1362 if (second == NIL) { 1363 return pathname.isWild() ? T : NIL; 1364 } 1365 if (second == Keyword.DIRECTORY) { 1366 if (pathname.directory instanceof Cons) { 1367 if (memq(Keyword.WILD, pathname.directory)) { 1368 return T; 1369 } 1370 if (memq(Keyword.WILD_INFERIORS, pathname.directory)) { 1371 return T; 1372 } 1373 } 1374 return NIL; 1375 } 1376 LispObject value; 1377 if (second == Keyword.HOST) { 1378 value = pathname.host; 1379 } else if (second == Keyword.DEVICE) { 1380 value = pathname.device; 1381 } else if (second == Keyword.NAME) { 1382 value = pathname.name; 1383 } else if (second == Keyword.TYPE) { 1384 value = pathname.type; 1385 } else if (second == Keyword.VERSION) { 1386 value = pathname.version; 1387 } else { 1388 return error(new ProgramError("Unrecognized keyword " 1389 + second.writeToString() + ".")); 1390 } 1391 if (value == Keyword.WILD || value == Keyword.WILD_INFERIORS) { 1392 return T; 1393 } else { 1394 return NIL; 1395 } 1396 } 1397 } 1398 1399 // ### merge-pathnames pathname &optional default-pathname default-version" 1400 private static final Primitive MERGE_PATHNAMES = new pf_merge_pathnames(); 1401 static final class pf_merge_pathnames extends Primitive { 1402 pf_merge_pathnames() { 1403 super("merge-pathnames", "pathname &optional default-pathname default-version"); 1404 } 1405 @Override 1406 public LispObject execute(LispObject arg) { 1407 Pathname pathname = coerceToPathname(arg); 1408 Pathname defaultPathname = 1402 1409 coerceToPathname(Symbol.DEFAULT_PATHNAME_DEFAULTS.symbolValue()); 1403 LispObject defaultVersion = Keyword.NEWEST; 1404 return mergePathnames(pathname, defaultPathname, defaultVersion); 1405 } 1406 1407 @Override 1408 public LispObject execute(LispObject first, LispObject second) { 1409 Pathname pathname = coerceToPathname(first); 1410 Pathname defaultPathname = 1410 LispObject defaultVersion = Keyword.NEWEST; 1411 return mergePathnames(pathname, defaultPathname, defaultVersion); 1412 } 1413 @Override 1414 public LispObject execute(LispObject first, LispObject second) { 1415 Pathname pathname = coerceToPathname(first); 1416 Pathname defaultPathname = 1411 1417 coerceToPathname(second); 1412 LispObject defaultVersion = Keyword.NEWEST; 1413 return mergePathnames(pathname, defaultPathname, defaultVersion); 1414 } 1415 1416 @Override 1417 public LispObject execute(LispObject first, LispObject second, 1418 LispObject third) { 1419 Pathname pathname = coerceToPathname(first); 1420 Pathname defaultPathname = 1418 LispObject defaultVersion = Keyword.NEWEST; 1419 return mergePathnames(pathname, defaultPathname, defaultVersion); 1420 } 1421 @Override 1422 public LispObject execute(LispObject first, LispObject second, 1423 LispObject third) { 1424 Pathname pathname = coerceToPathname(first); 1425 Pathname defaultPathname = 1421 1426 coerceToPathname(second); 1422 1423 1424 1425 };1427 LispObject defaultVersion = third; 1428 return mergePathnames(pathname, defaultPathname, defaultVersion); 1429 } 1430 } 1426 1431 1427 1432 public static final Pathname mergePathnames(Pathname pathname, Pathname defaultPathname) { … … 1475 1480 ((Cons)result.device).car = o; 1476 1481 } 1482 result.directory = p.directory; 1477 1483 } else { 1478 1484 result.directory = mergeDirectories(p.directory, d.directory); … … 1850 1856 1851 1857 // ### mkdir pathname 1852 private static final Primitive MKDIR = new mkdir();1853 private static class mkdir extends Primitive {1854 mkdir() {1858 private static final Primitive MKDIR = new pf_mkdir(); 1859 private static class pf_mkdir extends Primitive { 1860 pf_mkdir() { 1855 1861 super("mkdir", PACKAGE_SYS, false, "pathname"); 1856 1862 } … … 1872 1878 1873 1879 // ### rename-file filespec new-name => defaulted-new-name, old-truename, new-truename 1874 private static final Primitive RENAME_FILE = new rename_file();1875 private static class rename_file extends Primitive {1876 rename_file() {1880 private static final Primitive RENAME_FILE = new pf_rename_file(); 1881 private static class pf_rename_file extends Primitive { 1882 pf_rename_file() { 1877 1883 super("rename-file", "filespec new-name"); 1878 1884 } … … 1914 1920 1915 1921 // ### file-namestring pathname => namestring 1916 private static final Primitive FILE_NAMESTRING = new file_namestring();1917 private static class file_namestring extends Primitive {1918 file_namestring() {1922 private static final Primitive FILE_NAMESTRING = new pf_file_namestring(); 1923 private static class pf_file_namestring extends Primitive { 1924 pf_file_namestring() { 1919 1925 super("file-namestring", "pathname"); 1920 1926 } … … 1941 1947 1942 1948 // ### host-namestring pathname => namestring 1943 private static final Primitive HOST_NAMESTRING = new host_namestring();1944 private static class host_namestring extends Primitive {1945 host_namestring() {1949 private static final Primitive HOST_NAMESTRING = new pf_host_namestring(); 1950 private static class pf_host_namestring extends Primitive { 1951 pf_host_namestring() { 1946 1952 super("host-namestring", "pathname"); 1947 1953 } -
trunk/abcl/test/lisp/abcl/jar-file.lisp
r12424 r12486 222 222 #p"jar:file:/a/b/baz.jar!/foo") 223 223 224 (deftest jar-file.merge-pathnames.5 225 (merge-pathnames "jar:file:/a/b/c/foo.jar!/bar/baz.lisp") 226 #p"jar:file:/a/b/c/foo.jar!/bar/baz.lisp") 227 224 228 (deftest jar-file.truename.1 225 229 (signals-error (truename "jar:file:baz.jar!/foo") 226 230 'file-error) 227 231 t) 228 229 232 230 233 (deftest jar-file.pathname.1
Note: See TracChangeset
for help on using the changeset viewer.