Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
alexandria
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Fedorov
alexandria
Commits
f079acb4
Commit
f079acb4
authored
3 years ago
by
Gabor Melis
Browse files
Options
Downloads
Patches
Plain Diff
Fix READ-STREAM-CONTENT-INTO-STRING on abcl and cmucl
Paper over implementation incompatibilities in WITH-OPEN-FILE*.
parent
ec87ecc0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
alexandria-1/io.lisp
+16
-10
16 additions, 10 deletions
alexandria-1/io.lisp
with
16 additions
and
10 deletions
alexandria-1/io.lisp
+
16
−
10
View file @
f079acb4
...
...
@@ -6,16 +6,16 @@
(
defmacro
with-open-file*
((
stream
filespec
&key
direction
element-type
if-exists
if-does-not-exist
external-format
)
&body
body
)
"Just like WITH-OPEN-FILE, but NIL values in the keyword arguments
mean to use
the default value specified for OPEN."
"Just like WITH-OPEN-FILE, but NIL values in the keyword arguments
mean to use
the default value specified for OPEN."
(
once-only
(
direction
element-type
if-exists
if-does-not-exist
external-format
)
`
(
with-open-stream
(
,
stream
(
apply
#'
open
,
filespec
(
append
(
when
,
direction
(
list
:direction
,
direction
))
(
when
,
element-type
(
list
:element-type
,
element-type
))
(
list
:element-type
(
or
,
element-type
(
default-
element-type
))
)
(
when
,
if-exists
(
list
:if-exists
,
if-exists
))
(
when
,
if-does-not-exist
...
...
@@ -24,6 +24,16 @@ the default value specified for OPEN."
(
list
:external-format
,
external-format
)))))
,@
body
)))
(
defun
default-element-type
()
;; On Lispworks, ELEMENT-TYPE :DEFAULT selects the appropriate
;; subtype of CHARACTER for the given external format which can
;; represent all possible characters.
#+
lispworks
:default
;; The spec says that OPEN's default ELEMENT-TYPE (when it is not
;; specified) is CHARACTER, but on AllegroCL it's (UNSIGNED-BYTE 8).
;; No harm done by specifying it on other implementations.
#-
lispworks
'character
)
(
defmacro
with-input-from-file
((
stream-name
file-name
&rest
args
&key
(
direction
nil
direction-p
)
&allow-other-keys
)
...
...
@@ -67,10 +77,7 @@ which is only sent to WITH-OPEN-FILE when it's not NIL."
The EXTERNAL-FORMAT parameter will be passed directly to WITH-OPEN-FILE
unless it's NIL, which means the system default."
(
with-input-from-file
(
file-stream
pathname
:external-format
external-format
:element-type
'
:default
)
(
with-input-from-file
(
file-stream
pathname
:external-format
external-format
)
(
read-stream-content-into-string
file-stream
:buffer-size
buffer-size
)))
(
defun
write-string-into-file
(
string
pathname
&key
(
if-exists
:error
)
...
...
@@ -82,8 +89,7 @@ The EXTERNAL-FORMAT parameter will be passed directly to WITH-OPEN-FILE
unless it's NIL, which means the system default."
(
with-output-to-file
(
file-stream
pathname
:if-exists
if-exists
:if-does-not-exist
if-does-not-exist
:external-format
external-format
:element-type
'
:default
)
:external-format
external-format
)
(
write-sequence
string
file-stream
)))
(
defun
read-stream-content-into-byte-vector
(
stream
&key
((
%length
length
))
...
...
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
register
or
sign in
to comment