refactor(3p/lisp/mime4cl): use trivial-gray-streams
This should be a net positive for portability and lets us drop some of the CMUCL cruft (which we don't test anyway, CMU support may have regressed regardless). Change-Id: I85664d82d211177da1db9eebea65c956295b09f7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5067 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
25cb0ad32f
commit
f83ef56141
4 changed files with 16 additions and 51 deletions
1
third_party/lisp/mime4cl/default.nix
vendored
1
third_party/lisp/mime4cl/default.nix
vendored
|
@ -8,6 +8,7 @@ depot.nix.buildLisp.library {
|
||||||
deps = [
|
deps = [
|
||||||
depot.third_party.lisp.sclf
|
depot.third_party.lisp.sclf
|
||||||
depot.third_party.lisp.npg
|
depot.third_party.lisp.npg
|
||||||
|
depot.third_party.lisp.trivial-gray-streams
|
||||||
];
|
];
|
||||||
|
|
||||||
srcs = [
|
srcs = [
|
||||||
|
|
8
third_party/lisp/mime4cl/mime4cl.asd
vendored
8
third_party/lisp/mime4cl/mime4cl.asd
vendored
|
@ -1,6 +1,7 @@
|
||||||
;;; mime4cl.asd --- system definition
|
;;; mime4cl.asd --- system definition
|
||||||
|
|
||||||
;;; Copyright (C) 2005-2007, 2010 by Walter C. Pelissero
|
;;; Copyright (C) 2005-2007, 2010 by Walter C. Pelissero
|
||||||
|
;;; Copyright (C) 2022 by The TVL Authors
|
||||||
|
|
||||||
;;; Author: Walter C. Pelissero <walter@pelissero.de>
|
;;; Author: Walter C. Pelissero <walter@pelissero.de>
|
||||||
;;; Project: mime4cl
|
;;; Project: mime4cl
|
||||||
|
@ -20,11 +21,6 @@
|
||||||
|
|
||||||
(in-package :cl-user)
|
(in-package :cl-user)
|
||||||
|
|
||||||
#+(and cmu (not gray-streams))
|
|
||||||
(eval-when (:compile-toplevel :load-toplevel :execute)
|
|
||||||
(ext:without-package-locks
|
|
||||||
(load "library:subsystems/gray-streams-library")))
|
|
||||||
|
|
||||||
(defpackage :mime4cl-system
|
(defpackage :mime4cl-system
|
||||||
(:use :common-lisp :asdf))
|
(:use :common-lisp :asdf))
|
||||||
|
|
||||||
|
@ -40,7 +36,7 @@
|
||||||
"A collection of Common Lisp primitives to forge and handle
|
"A collection of Common Lisp primitives to forge and handle
|
||||||
MIME mail contents."
|
MIME mail contents."
|
||||||
:licence "LGPL"
|
:licence "LGPL"
|
||||||
:depends-on (:npg :sclf)
|
:depends-on (:npg :sclf :trivial-gray-streams)
|
||||||
:components
|
:components
|
||||||
((:file "package")
|
((:file "package")
|
||||||
(:file "mime" :depends-on ("package" "endec" "streams"))
|
(:file "mime" :depends-on ("package" "endec" "streams"))
|
||||||
|
|
5
third_party/lisp/mime4cl/package.lisp
vendored
5
third_party/lisp/mime4cl/package.lisp
vendored
|
@ -1,6 +1,7 @@
|
||||||
;;; package.lisp --- package declaration
|
;;; package.lisp --- package declaration
|
||||||
|
|
||||||
;;; Copyright (C) 2005-2007, 2010 by Walter C. Pelissero
|
;;; Copyright (C) 2005-2007, 2010 by Walter C. Pelissero
|
||||||
|
;;; Copyright (C) 2022 The TVL Authors
|
||||||
|
|
||||||
;;; Author: Walter C. Pelissero <walter@pelissero.de>
|
;;; Author: Walter C. Pelissero <walter@pelissero.de>
|
||||||
;;; Project: mime4cl
|
;;; Project: mime4cl
|
||||||
|
@ -22,9 +23,7 @@
|
||||||
|
|
||||||
(defpackage :mime4cl
|
(defpackage :mime4cl
|
||||||
(:nicknames :mime)
|
(:nicknames :mime)
|
||||||
(:use :common-lisp :npg :sclf
|
(:use :common-lisp :npg :sclf :trivial-gray-streams)
|
||||||
;; for Gray streams
|
|
||||||
#+cmu :extensions #+sbcl :sb-gray)
|
|
||||||
;; this is stuff that comes from SCLF and clashes with CMUCL's EXT
|
;; this is stuff that comes from SCLF and clashes with CMUCL's EXT
|
||||||
;; package
|
;; package
|
||||||
(:shadowing-import-from :sclf
|
(:shadowing-import-from :sclf
|
||||||
|
|
53
third_party/lisp/mime4cl/streams.lisp
vendored
53
third_party/lisp/mime4cl/streams.lisp
vendored
|
@ -1,12 +1,12 @@
|
||||||
;;; eds.lisp --- En/De-coding Streams
|
;;; streams.lisp --- En/De-coding Streams
|
||||||
|
|
||||||
;;; Copyright (C) 2012 by Walter C. Pelissero
|
;;; Copyright (C) 2012 by Walter C. Pelissero
|
||||||
;;; Copyright (C) 2021 by the TVL Authors
|
;;; Copyright (C) 2021-2022 by the TVL Authors
|
||||||
|
|
||||||
;;; Author: Walter C. Pelissero <walter@pelissero.de>
|
;;; Author: Walter C. Pelissero <walter@pelissero.de>
|
||||||
;;; Project: mime4cl
|
;;; Project: mime4cl
|
||||||
|
|
||||||
#+cmu (ext:file-comment "$Module: eds.lisp")
|
#+cmu (ext:file-comment "$Module: streams.lisp")
|
||||||
|
|
||||||
;;; This library is free software; you can redistribute it and/or
|
;;; This library is free software; you can redistribute it and/or
|
||||||
;;; modify it under the terms of the GNU Lesser General Public License
|
;;; modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -23,39 +23,6 @@
|
||||||
|
|
||||||
(in-package :mime4cl)
|
(in-package :mime4cl)
|
||||||
|
|
||||||
#+cmu
|
|
||||||
(eval-when (:load-toplevel :compile-toplevel :execute)
|
|
||||||
;; CMUCL doesn't provide the STREAM-FILE-POSITION method in its
|
|
||||||
;; implementation of Gray streams. We patch it in ourselves.
|
|
||||||
(defgeneric stream-file-position (stream &optional position))
|
|
||||||
(defun my-file-position (stream &optional position)
|
|
||||||
(stream-file-position stream position))
|
|
||||||
(defvar *original-file-position-function*
|
|
||||||
(prog1
|
|
||||||
(symbol-function 'file-position)
|
|
||||||
(setf (symbol-function 'file-position) (symbol-function 'my-file-position))))
|
|
||||||
(defmethod stream-file-position (stream &optional position)
|
|
||||||
(if position
|
|
||||||
(funcall *original-file-position-function* stream position)
|
|
||||||
(funcall *original-file-position-function* stream)))
|
|
||||||
|
|
||||||
;; oddly CMUCL doesn't seem to provide a default for STREAM-READ-SEQUENCE
|
|
||||||
(defmacro make-read-sequence (stream-type element-reader)
|
|
||||||
`(defmethod stream-read-sequence ((stream ,stream-type) seq &optional start end)
|
|
||||||
(unless start
|
|
||||||
(setf start 0))
|
|
||||||
(unless end
|
|
||||||
(setf end (length seq)))
|
|
||||||
(loop
|
|
||||||
for i from start below end
|
|
||||||
for b = (,element-reader stream)
|
|
||||||
until (eq b :eof)
|
|
||||||
do (setf (elt seq i) b)
|
|
||||||
finally (return i))))
|
|
||||||
|
|
||||||
(make-read-sequence fundamental-binary-input-stream stream-read-byte)
|
|
||||||
(make-read-sequence fundamental-character-input-stream stream-read-char))
|
|
||||||
|
|
||||||
(defclass coder-stream-mixin ()
|
(defclass coder-stream-mixin ()
|
||||||
((real-stream :type stream
|
((real-stream :type stream
|
||||||
:initarg :stream
|
:initarg :stream
|
||||||
|
@ -63,9 +30,11 @@
|
||||||
(dont-close :initform nil
|
(dont-close :initform nil
|
||||||
:initarg :dont-close)))
|
:initarg :dont-close)))
|
||||||
|
|
||||||
(defmethod stream-file-position ((stream coder-stream-mixin) &optional position)
|
(defmethod stream-file-position ((stream coder-stream-mixin))
|
||||||
(apply #'file-position (remove nil (list (slot-value stream 'real-stream)
|
(file-position (slot-value stream 'real-stream)))
|
||||||
position))))
|
|
||||||
|
(defmethod (setf stream-file-position) (newval (stream coder-stream-mixin))
|
||||||
|
(file-position (slot-value stream 'real-stream) newval))
|
||||||
|
|
||||||
(defclass coder-input-stream-mixin (fundamental-binary-input-stream coder-stream-mixin)
|
(defclass coder-input-stream-mixin (fundamental-binary-input-stream coder-stream-mixin)
|
||||||
())
|
())
|
||||||
|
|
Loading…
Reference in a new issue