[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e51f904676: Fix yank-media-types--format decoding
From: |
Lars Ingebrigtsen |
Subject: |
master e51f904676: Fix yank-media-types--format decoding |
Date: |
Sat, 5 Feb 2022 01:01:06 -0500 (EST) |
branch: master
commit e51f9046762a4f34ece910802aa7f2007303124d
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix yank-media-types--format decoding
* lisp/yank-media.el (yank-media-types--format): Check that we
really have some nuls.
---
lisp/yank-media.el | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/lisp/yank-media.el b/lisp/yank-media.el
index 9836082fb2..8c75877724 100644
--- a/lisp/yank-media.el
+++ b/lisp/yank-media.el
@@ -162,23 +162,26 @@ non-supported selection data types."
(when (zerop (elt data i))
(setf (aref stats (mod i 2))
(1+ (aref stats (mod i 2))))))
- ;; If we have more than 90% every-other nul, then it's
- ;; pretty likely to be utf-16.
- (cond
- ((> (if (zerop (elt stats 1))
- 1
- (/ (float (elt stats 0))
- (float (elt stats 1))))
- 0.9)
- ;; Big endian.
- 'utf-16-be)
- ((> (if (zerop (elt stats 0))
- 1
- (/ (float (elt stats 1))
- (float (elt stats 0))))
- 0.9)
- ;; Little endian.
- 'utf-16-le))))))
+ ;; We have some nuls...
+ (and (not (and (zerop (elt stats 0))
+ (zerop (elt stats 1))))
+ ;; If we have more than 90% every-other nul, then it's
+ ;; pretty likely to be utf-16.
+ (cond
+ ((> (if (zerop (elt stats 1))
+ 1
+ (/ (float (elt stats 0))
+ (float (elt stats 1))))
+ 0.9)
+ ;; Big endian.
+ 'utf-16-be)
+ ((> (if (zerop (elt stats 0))
+ 1
+ (/ (float (elt stats 1))
+ (float (elt stats 0))))
+ 0.9)
+ ;; Little endian.
+ 'utf-16-le)))))))
(if coding-system
(decode-coding-string data coding-system)
;; Some programs add a nul character at the end of text/*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master e51f904676: Fix yank-media-types--format decoding,
Lars Ingebrigtsen <=