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

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 @@ ...@@ -74,7 +74,7 @@
:licence "MIT" :licence "MIT"
:description "Another System Definition Facility" :description "Another System Definition Facility"
:long-description "ASDF builds Common Lisp software organized into defined systems." :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 () :depends-on ()
#+asdf3 :encoding #+asdf3 :utf-8 #+asdf3 :encoding #+asdf3 :utf-8
;; For most purposes, asdf itself specially counts as a builtin system. ;; For most purposes, asdf itself specially counts as a builtin system.
......
;;; -*- mode: Common-Lisp; Base: 10 ; Syntax: ANSI-Common-Lisp -*- ;;; -*- 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: ;;; Feedback, bug reports, and patches are all welcome:
;;; please mail to <asdf-devel@common-lisp.net>. ;;; please mail to <asdf-devel@common-lisp.net>.
......
...@@ -180,6 +180,23 @@ by /bin/sh in POSIX" ...@@ -180,6 +180,23 @@ by /bin/sh in POSIX"
(declare (ignorable x)) (declare (ignorable x))
(apply 'slurp-input-stream *standard-output* stream keys)) (apply 'slurp-input-stream *standard-output* stream keys))
(defmethod slurp-input-stream ((pathname pathname) input
&key
(element-type *default-stream-element-type*)
(external-format *utf-8-external-format*)
(if-exists :rename-and-delete)
(if-does-not-exist :create)
buffer-size
linewise)
(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)
(copy-stream-to-stream
input output
:element-type element-type :buffer-size buffer-size :linewise linewise)))
(defmethod slurp-input-stream (x stream (defmethod slurp-input-stream (x stream
&key linewise prefix (element-type 'character) buffer-size &key linewise prefix (element-type 'character) buffer-size
&allow-other-keys) &allow-other-keys)
...@@ -234,6 +251,7 @@ Otherwise, the output will be processed by SLURP-INPUT-STREAM, ...@@ -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, 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. 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." 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)) (declare (ignorable ignore-error-status element-type external-format))
#-(or abcl allegro clisp clozure cmu cormanlisp ecl gcl lispworks mcl sbcl scl xcl) #-(or abcl allegro clisp clozure cmu cormanlisp ecl gcl lispworks mcl sbcl scl xcl)
(error "RUN-PROGRAM not implemented for this Lisp") (error "RUN-PROGRAM not implemented for this Lisp")
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#:*default-encoding* #:*utf-8-external-format* #:*default-encoding* #:*utf-8-external-format*
#:with-safe-io-syntax #:call-with-safe-io-syntax #:safe-read-from-string #: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
#: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! #:finish-outputs #:format! #:safe-format!
#:copy-stream-to-stream #:concatenate-files #:copy-file #:copy-stream-to-stream #:concatenate-files #:copy-file
#:slurp-stream-string #:slurp-stream-lines #:slurp-stream-line #:slurp-stream-string #:slurp-stream-lines #:slurp-stream-line
...@@ -186,10 +186,33 @@ Other keys are accepted but discarded." ...@@ -186,10 +186,33 @@ Other keys are accepted but discarded."
:if-does-not-exist if-does-not-exist) :if-does-not-exist if-does-not-exist)
(funcall thunk s))) (funcall thunk s)))
(defmacro with-input-file ((var pathname &rest keys &key element-type external-format) &body body) (defmacro with-input-file ((var pathname &rest keys
(declare (ignore element-type external-format)) &key element-type external-format if-does-not-exist)
`(call-with-input-file ,pathname #'(lambda (,var) ,@body) ,@keys))) &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
&key
(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 ;;; Ensure output buffers are flushed
(with-upgradability () (with-upgradability ()
......
...@@ -52,7 +52,7 @@ You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSIO ...@@ -52,7 +52,7 @@ You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSIO
;; "3.4.5.67" would be a development version in the official upstream of 3.4.5. ;; "3.4.5.67" would be a development version in the official upstream of 3.4.5.
;; "3.4.5.0.8" would be your eighth local modification of official release 3.4.5 ;; "3.4.5.0.8" would be your eighth local modification of official release 3.4.5
;; "3.4.5.67.8" would be your eighth local modification of development version 3.4.5.67 ;; "3.4.5.67.8" would be your eighth local modification of development version 3.4.5.67
(asdf-version "2.33.5") (asdf-version "2.33.6")
(existing-version (asdf-version))) (existing-version (asdf-version)))
(setf *asdf-version* asdf-version) (setf *asdf-version* asdf-version)
(when (and existing-version (not (equal asdf-version existing-version))) (when (and existing-version (not (equal asdf-version existing-version)))
......
Markdown is supported
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