chore(3p/lisp/mime4cl): remove MIME-PART-SIZE and MIME-BODY-SIZE

These functions are not very useful—as far as I'm aware at least—, are
not implemented very efficiently and totally untested. Remove them for
now. See also r/8978.

Change-Id: If9d277b460c3ed728a171bc29dd626c4c5fc0313
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12868
Reviewed-by: sterni <sternenseemann@systemli.org>
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
sterni 2024-12-05 13:57:36 +01:00 committed by clbot
parent 856886f01d
commit a31af5233c
4 changed files with 2 additions and 68 deletions

View file

@ -42,9 +42,4 @@ depot.nix.buildLisp.library {
expression = "(rtest:do-tests)";
};
# limited by sclf
brokenOn = [
"ecl"
];
}

View file

@ -63,8 +63,6 @@
#:save-file-excursion
#:read-file
#:file-size
#:promise
#:make-promise
#:lazy
@ -267,16 +265,6 @@ ELEMENT-TYPE."
seq)
default)))
;; FILES
;; FILE-LENGTH is a bit idiosyncratic in this respect. Besides, Unix
;; allows to get to know the file size without being able to open a
;; file; just ask politely.
(defun file-size (pathname)
#+sbcl (sb-posix:stat-size (sb-posix:stat pathname))
#+ccl (ccl:file-data-size pathname)
#-(or sbcl ccl) (error "nyi"))
;; LAZY
(defstruct promise

View file

@ -204,24 +204,6 @@ because they are stored in dedicated slots in MIME-PART.")
(defun mime-body-stream (mime-part)
(make-input-adapter (mime-body mime-part)))
(defun mime-body-length (mime-part)
(let ((body (mime-body mime-part)))
;; here the stream type is missing on purpose, because we may not
;; be able to size the length of a stream
(etypecase body
(string
(length body))
(vector
(length body))
(pathname
(file-size body))
(file-portion
(with-open-stream (in (open-decoded-file-portion body))
(loop
for byte = (read-byte in nil)
while byte
count byte))))))
(defmacro with-input-from-mime-body-stream ((stream part) &body forms)
`(with-open-stream (,stream (mime-body-stream ,part))
,@forms))
@ -386,10 +368,6 @@ that may change this.")
(:multipart mime-multipart)
(:message mime-message)))
(defgeneric mime-part-size (part)
(:documentation
"Return the size in bytes of the body of a MIME part."))
(defgeneric print-mime-part (part stream)
(:documentation
"Output to STREAM one of the possible human-readable representation
@ -847,31 +825,6 @@ returns a MIME-MESSAGE object."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; fall back method
(defmethod mime-part-size ((part mime-part))
(let ((body (mime-body part)))
(typecase body
(pathname
(file-size body))
(string
(length body))
(vector
(length body))
(t nil))))
(defmethod mime-part-size ((part mime-multipart))
(loop
for p in (mime-parts part)
for size = (mime-part-size p)
unless size
return nil
sum size))
(defmethod mime-part-size ((part mime-message))
(mime-part-size (mime-body part)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmethod print-mime-part ((part mime-multipart) (out stream))
(case (mime-subtype part)
(:alternative
@ -916,8 +869,8 @@ returns a MIME-MESSAGE object."
(print-mime-part (mime-body part) out)))
(defmethod print-mime-part ((part mime-part) (out stream))
(format out "~&[ ~A subtype=~A ~@[description=~S ~]~@[size=~A~] ]~%"
(type-of part) (mime-subtype part) (mime-description part) (mime-part-size part)))
(format out "~&[ ~A subtype=~A ~@[description=~S ~]]~%"
(type-of part) (mime-subtype part) (mime-description part)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -44,11 +44,9 @@
#:mime-application
#:mime-video
#:mime-description
#:mime-part-size
#:mime-subtype
#:mime-body
#:mime-body-stream
#:mime-body-length
#:mime-parts
#:mime-part-p
#:mime-type