Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PARSE-NAMESTRING fails to explicitly denote current directory #666

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/org/armedbear/lisp/Pathname.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,6 @@ private static final Pathname init(String s) {
result.setDirectory(new Cons(Keyword.RELATIVE));
return result;
}
if (s.startsWith("./"))
{ s = s.substring(2); }
if (s.equals("..") || s.equals("../")) {
result.setDirectory(list(Keyword.RELATIVE, Keyword.UP));
return result;
Expand Down Expand Up @@ -425,6 +423,9 @@ private static final LispObject parseDirectory(String d) {
if (d.equals("/") || (Utilities.isPlatformWindows && d.equals("\\"))) {
return new Cons(Keyword.ABSOLUTE);
}
if (d.equals("./")) {
return new Cons(Keyword.RELATIVE);
}
LispObject result;
if (d.startsWith("/") || (Utilities.isPlatformWindows && d.startsWith("\\"))) {
result = new Cons(Keyword.ABSOLUTE);
Expand Down
71 changes: 71 additions & 0 deletions t/namestring.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
;;;; <https://github.com/armedbear/abcl/issues/656>
#|
(parse-namestring "./foo") evaluates to #p"foo", instead of #p"./foo".

Most Lisp implementation evaluate to #p"./foo", but I don't think this is in the standard.

ABCL supports current directory in paths though, using make-pathname:

(make-pathname :directory '(:relative ".") :name "foo") => #P"./foo".

So it is only parse-namestring that would need to be modified.
|#

(prove:plan 1)

(prove:is
(pathname-directory (parse-namestring "./foo"))
'(:relative ".")
"Whether the namestring of current directory explicitly roundtrips")


;; (describe #p"./foo")
#| ABCL
#P"foo" is an object of type PATHNAME:
HOST NIL
DEVICE NIL
DIRECTORY NIL
NAME "foo"
TYPE NIL
VERSION NIL
; No value ;
|#

#| SBCL
#P"./foo"
[pathname]

HOST = #<SB-IMPL::UNIX-HOST {70031676C3}>
DIRECTORY = (:RELATIVE ".")
NAME = "foo"
VERSION = :NEWEST
; No value
|#

#| CCL
P"./foo"
Type: PATHNAME
Class: #<BUILT-IN-CLASS PATHNAME>
TYPE: (PATHNAME . #<CCL::CLASS-WRAPPER PATHNAME #x30004035E6DD>)
%PATHNAME-DIRECTORY: (:RELATIVE ".")
%PATHNAME-NAME: "foo"
%PATHNAME-TYPE: NIL
%PHYSICAL-PATHNAME-VERSION: :NEWEST
%PHYSICAL-PATHNAME-DEVICE: NIL
|#

#| ECL
#<pathname 0x107138140>
--------------------
A pathname.
Namestring: "foo"
Host: NIL
Device: NIL
Directory: (:RELATIVE)
Name: "foo"
Type: NIL
Version: :NEWEST

|#

(prove:finalize)