Changeset 9993


Ignore:
Timestamp:
09/21/05 18:51:17 (16 years ago)
Author:
piso
Message:

Work in progress.

Location:
trunk/j/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Pathname.java

    r9992 r9993  
    33 *
    44 * Copyright (C) 2003-2005 Peter Graves
    5  * $Id: Pathname.java,v 1.91 2005-09-21 17:35:49 piso Exp $
     5 * $Id: Pathname.java,v 1.92 2005-09-21 18:51:17 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    110110                s = System.getProperty("user.home").concat(s.substring(1));
    111111        }
    112         namestring = s;
    113112        if (s.equals(".") || s.equals("./")) {
    114113            directory = new Cons(Keyword.RELATIVE);
     
    119118            return;
    120119        }
     120        namestring = s;
    121121        if (Utilities.isPlatformWindows()) {
    122122            if (s.length() >= 2 && s.charAt(1) == ':') {
     
    262262        }
    263263        sb.append(getDirectoryNamestring());
    264         if (name instanceof AbstractString)
    265             sb.append(name.getStringValue());
    266         else if (name == Keyword.WILD)
     264        if (name instanceof AbstractString) {
     265            String n = name.getStringValue();
     266            if (n.indexOf(File.separatorChar) >= 0) {
     267                Debug.assertTrue(namestring == null);
     268                return null;
     269            }
     270            sb.append(n);
     271        } else if (name == Keyword.WILD)
    267272            sb.append('*');
    268273        if (type != NIL) {
     
    417422                useNamestring = true;
    418423                if (printReadably) {
    419                     // We have a namestring. Check for non-NIL values of pathname
    420                     // components that can't be read from the namestring.
     424                    // We have a namestring. Check for pathname components that
     425                    // can't be read from the namestring.
    421426                    if (host != NIL || version != NIL) {
    422427                        useNamestring = false;
    423                     } else if (Utilities.isPlatformWindows()) {
    424                         if (version != NIL)
     428                    } else if (name instanceof AbstractString) {
     429                        String n = name.getStringValue();
     430                        if (n.equals(".") || n.equals(".."))
     431                            useNamestring = false;
     432                        else if (n.indexOf(File.separatorChar) >= 0)
    425433                            useNamestring = false;
    426434                    }
  • trunk/j/src/org/armedbear/lisp/tests/pathname-tests.lisp

    r9991 r9993  
    6767              (first args) (second args) (third args) result expected))))
    6868
     69(defmacro check-readable (pathname)
     70  `(expect (equal ,pathname (read-from-string (write-to-string ,pathname :readably t)))))
     71
    6972(check-physical-pathname #p"/" '(:absolute) nil nil)
    7073(check-physical-pathname #p"/foo" '(:absolute) "foo" nil)
     
    8992(check-physical-pathname #p"x.lisprc" nil "x" "lisprc")
    9093
     94#-allegro
     95(check-physical-pathname (make-pathname :name ".") nil "." nil)
     96#+allegro
     97(check-physical-pathname (make-pathname :name ".") '(:relative) nil nil)
     98
     99(check-readable (make-pathname :name "."))
     100
    91101;; #p"."
    92102#+(or allegro abcl cmu)
     
    103113;; Is this more exact?
    104114(check-physical-pathname #p"./" '(:relative ".") nil nil)
     115
     116#-allegro
     117(check-physical-pathname (make-pathname :name "..") nil ".." nil)
     118#+allegro
     119(check-physical-pathname (make-pathname :name "..") '(:relative :back) nil nil)
     120
    105121
    106122;; #p".."
     
    127143#+(or allegro abcl cmu)
    128144(check-physical-pathname #p"..." nil "..." nil)
     145#+(or allegro abcl cmu)
     146(check-physical-pathname #p"......" nil "......" nil)
    129147(check-physical-pathname #p"foo.*" nil "foo" :wild)
     148
     149#-(or sbcl allegro)
     150(expect (string= (namestring (make-pathname :name "..")) ".."))
     151#+allegro
     152(expect (string= (namestring (make-pathname :name "..")) "../"))
     153
     154(expect (string= (namestring (make-pathname :directory '(:relative :up))) "../"))
     155
     156;; Silly names.
     157#+clisp
     158(expect (signals-error (make-pathname :name "abc/def") 'error))
     159#-(or allegro clisp sbcl)
     160(check-readable (make-pathname :name "abc/def"))
    130161
    131162;; If the prefix isn't a defined logical host, it's not a logical pathname.
Note: See TracChangeset for help on using the changeset viewer.