Commit 21a7ba3f authored by Francois-Rene Rideau's avatar Francois-Rene Rideau
Browse files

2.33.6: have slurp-input-stream (and hence run-program) recognize a pathname as output.

Define with-output-file and call-with-output-file for that.
parent 19cd244c
......@@ -74,7 +74,7 @@
:licence "MIT"
:description "Another System Definition Facility"
:long-description "ASDF builds Common Lisp software organized into defined systems."
:version "2.33.5" ;; to be automatically updated by make bump-version
:version "2.33.6" ;; to be automatically updated by make bump-version
:depends-on ()
#+asdf3 :encoding #+asdf3 :utf-8
;; For most purposes, asdf itself specially counts as a builtin system.
;;; -*- mode: Common-Lisp; Base: 10 ; Syntax: ANSI-Common-Lisp -*-
;;; This is ASDF 2.33.5: Another System Definition Facility.
;;; This is ASDF 2.33.6: Another System Definition Facility.
;;; Feedback, bug reports, and patches are all welcome:
;;; please mail to <>.
......@@ -180,6 +180,23 @@ by /bin/sh in POSIX"
(declare (ignorable x))
(apply 'slurp-input-stream *standard-output* stream keys))
(defmethod slurp-input-stream ((pathname pathname) input
(element-type *default-stream-element-type*)
(external-format *utf-8-external-format*)
(if-exists :rename-and-delete)
(if-does-not-exist :create)
(with-output-file (output pathname
:element-type element-type
:external-format external-format
:if-exists if-exists
:if-does-not-exist if-does-not-exist)
input output
:element-type element-type :buffer-size buffer-size :linewise linewise)))
(defmethod slurp-input-stream (x stream
&key linewise prefix (element-type 'character) buffer-size
......@@ -234,6 +251,7 @@ Otherwise, the output will be processed by SLURP-INPUT-STREAM,
using OUTPUT as the first argument, and return whatever it returns,
e.g. using :OUTPUT :STRING will have it return the entire output stream as a string.
Use ELEMENT-TYPE and EXTERNAL-FORMAT for the stream passed to the OUTPUT processor."
;; TODO: specially recognize :output pathname ?
(declare (ignorable ignore-error-status element-type external-format))
#-(or abcl allegro clisp clozure cmu cormanlisp ecl gcl lispworks mcl sbcl scl xcl)
(error "RUN-PROGRAM not implemented for this Lisp")
......@@ -12,7 +12,7 @@
#:*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-input-file #:call-with-input-file
#:with-input-file #:call-with-input-file #:with-output-file #:call-with-output-file
#:finish-outputs #:format! #:safe-format!
#:copy-stream-to-stream #:concatenate-files #:copy-file
#:slurp-stream-string #:slurp-stream-lines #:slurp-stream-line
......@@ -186,10 +186,33 @@ Other keys are accepted but discarded."
:if-does-not-exist if-does-not-exist)
(funcall thunk s)))
(defmacro with-input-file ((var pathname &rest keys &key element-type external-format) &body body)
(declare (ignore element-type external-format))
`(call-with-input-file ,pathname #'(lambda (,var) ,@body) ,@keys)))
(defmacro with-input-file ((var pathname &rest keys
&key element-type external-format if-does-not-exist)
&body body)
(declare (ignore element-type external-format if-does-not-exist))
`(call-with-input-file ,pathname #'(lambda (,var) ,@body) ,@keys))
(defun call-with-output-file (pathname thunk
(element-type *default-stream-element-type*)
(external-format *utf-8-external-format*)
(if-exists :rename-and-delete)
(if-does-not-exist :create))
"Open FILE for input with given recognizes options, call THUNK with the resulting stream.
Other keys are accepted but discarded."
#+gcl2.6 (declare (ignore external-format))
(with-open-file (s pathname :direction :output
:element-type element-type
#-gcl2.6 :external-format #-gcl2.6 external-format
:if-exists if-exists
:if-does-not-exist if-does-not-exist)
(funcall thunk s)))
(defmacro with-output-file ((var pathname &rest keys
&key element-type external-format if-exists if-does-not-exist)
&body body)
(declare (ignore element-type external-format if-exists if-does-not-exist))
`(call-with-output-file ,pathname #'(lambda (,var) ,@body) ,@keys)))
;;; Ensure output buffers are flushed
(with-upgradability ()
......@@ -52,7 +52,7 @@ You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSIO
;; "" would be a development version in the official upstream of 3.4.5.
;; "" would be your eighth local modification of official release 3.4.5
;; "" would be your eighth local modification of development version
(asdf-version "2.33.5")
(asdf-version "2.33.6")
(existing-version (asdf-version)))
(setf *asdf-version* asdf-version)
(when (and existing-version (not (equal asdf-version existing-version)))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment