Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
asdf
asdf
Commits
49f75356
Commit
49f75356
authored
Jul 29, 2014
by
Francois-Rene Rideau
Browse files
Add input-string, a symmetric function to output-string.
parent
2c4e895e
Changes
1
Hide whitespace changes
Inline
Side-by-side
uiop/stream.lisp
View file @
49f75356
...
...
@@ -12,7 +12,7 @@
#:encoding-external-format
#:*encoding-external-format-hook*
#:default-encoding-external-format
#:*default-encoding*
#:*utf-8-external-format*
#:with-safe-io-syntax
#:call-with-safe-io-syntax
#:safe-read-from-string
#:with-output
#:output-string
#:with-input
#:with-output
#:output-string
#:with-input
#:input-string
#:with-input-file
#:call-with-input-file
#:with-output-file
#:call-with-output-file
#:null-device-pathname
#:call-with-null-input
#:with-null-input
#:call-with-null-output
#:with-null-output
...
...
@@ -263,8 +263,14 @@ Otherwise, signal an error."
(
defmacro
with-input
((
input-var
&optional
(
value
input-var
))
&body
body
)
"Bind INPUT-VAR to an input stream, coercing VALUE (default: previous binding of INPUT-VAR)
as per CALL-WITH-INPUT, and evaluate BODY within the scope of this binding."
`
(
call-with-input
,
value
#'
(
lambda
(
,
input-var
)
,@
body
))))
`
(
call-with-input
,
value
#'
(
lambda
(
,
input-var
)
,@
body
)))
(
defun
input-string
(
&optional
input
)
"If the desired INPUT is a string, return that string; otherwise slurp the INPUT into a string
and return that"
(
if
(
stringp
input
)
input
(
with-input
(
input
)
(
funcall
'slurp-stream-string
input
)))))
;;; Null device
(
with-upgradability
()
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment