Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cmucl
cmucl
Commits
bdd7294f
Commit
bdd7294f
authored
Jul 21, 2023
by
Raymond Toy
Browse files
Options
Downloads
Patches
Plain Diff
Fix
#171
: Readably print pathnames with :unspecific
parent
5d4b0622
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!134
Fix #171: Readably print pathnames with :unspecific
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/code/pathname.lisp
+59
-44
59 additions, 44 deletions
src/code/pathname.lisp
tests/pathname.lisp
+28
-0
28 additions, 0 deletions
tests/pathname.lisp
with
87 additions
and
44 deletions
src/code/pathname.lisp
+
59
−
44
View file @
bdd7294f
...
...
@@ -121,24 +121,39 @@
(
defun
%print-pathname
(
pathname
stream
depth
)
(
declare
(
ignore
depth
))
(
let*
((
host
(
%pathname-host
pathname
))
(
device
(
%pathname-device
pathname
))
(
directory
(
%pathname-directory
pathname
))
(
name
(
%pathname-name
pathname
))
(
type
(
%pathname-type
pathname
))
(
version
(
%pathname-version
pathname
))
(
unspecific-p
(
or
(
eq
device
:unspecific
)
(
eq
name
:unspecific
)
(
eq
type
:unspecific
)
(
eq
version
:unspecific
)))
(
namestring
(
if
host
(
handler-case
(
namestring
pathname
)
(
error
nil
))
nil
)))
(
cond
(
namestring
;; A pathname with :UNSPECIFIC components has a namestring that
;; ignores :UNSPECIFIC (and NIL). Thus the namestring exists, but
;; we want to use our special syntax to print the pathname
;; readably when :UNSPECIFIC occurs.
(
cond
((
and
namestring
(
not
unspecific-p
))
(
if
(
or
*print-escape*
*print-readably*
)
(
format
stream
"#P~S"
namestring
)
(
format
stream
"~A"
namestring
)))
(
t
(
let
((
device
(
%pathname-device
pathname
))
(
directory
(
%pathname-directory
pathname
))
(
name
(
%pathname-name
pathname
))
(
type
(
%pathname-type
pathname
))
(
version
(
%pathname-version
pathname
)))
(
cond
((
every
#'
(
lambda
(
d
)
(
cond
((
and
;; We only use the extension if the pathname does
;; not contain a pattern object which doesn't print
;; readably. Search-lists, which are part of the
;; directory component, are excluded too.
(
not
(
typep
name
'pattern
))
(
not
(
typep
type
'pattern
))
(
every
#'
(
lambda
(
d
)
(
or
(
stringp
d
)
(
symbolp
d
)))
(
cdr
directory
))
(
cdr
directory
))
)
;; A CMUCL extension. If we have an unprintable
;; pathname, convert it to a form that would be
;; suitable as args to MAKE-PATHNAME to recreate
...
...
This diff is collapsed.
Click to expand it.
tests/pathname.lisp
+
28
−
0
View file @
bdd7294f
...
...
@@ -83,3 +83,31 @@
and
type
=
(
pathname-type
f
)
do
(
assert-true
(
and
(
null
name
)
(
null
type
))
f
))))
;; Test that pathnames with :unspecific components are printed using
;; our extension to make :unspecific explicit.
(
define-test
issue.171.unspecific
(
:tag
:issues
)
(
flet
((
output
(
path
)
(
with-output-to-string
(
s
)
(
write
path
:stream
s
))))
(
dolist
(
test
(
list
(
list
(
make-pathname
:name
"foo"
:type
:unspecific
)
"#P(:NAME \"foo\" :TYPE :UNSPECIFIC)"
"foo"
)
(
list
(
make-pathname
:name
:unspecific
:type
"foo"
)
"#P(:NAME :UNSPECIFIC :TYPE \"foo\")"
".foo"
)
(
list
(
make-pathname
:name
"foo"
:type
"txt"
:version
:unspecific
)
"#P(:NAME \"foo\" :TYPE \"txt\" :VERSION :UNSPECIFIC)"
"foo.txt"
)
(
list
(
make-pathname
:device
:unspecific
)
"#P(:DEVICE :UNSPECIFIC)"
""
)))
(
destructuring-bind
(
pathname
printed-value
namestring
)
test
(
assert-equal
printed-value
(
output
pathname
))
(
assert-equal
namestring
(
namestring
pathname
))))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment