* [patch] fix of quoted-printable vs base64 chooser function
@ 1999-09-21 22:07 Johan Kullstam
0 siblings, 0 replies; only message in thread
From: Johan Kullstam @ 1999-09-21 22:07 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 1144 bytes --]
this fixes the quoted-printable or base64 selector function in
mm-encode.el. the pgnus-0.96 function is totally broken.
the new improved function is
(defun mm-qp-or-base64 ()
(save-excursion
(let ((limit (min (point-max) (+ 2000 (point-min))))
(n8bit 0))
(goto-char (point-min))
(skip-chars-forward "\x20-\x7f\r\n\t" limit)
(while (< (point) limit)
(incf n8bit)
(forward-char 1)
(skip-chars-forward "\x20-\x7f\r\n\t" limit))
(if (< (* 6 n8bit) (- limit (point-min)))
'quoted-printable
'base64))))
which fixes the following problems with the old function.
* long attachments are always quoted-printable
the old function used narrow to limit to 1000 chars and then
compared number of 8 bit chars divided by the buffer-size to 0.1667.
buffer-size is the complete non-narrowed buffer which causes
quoted-printable to always be chosen for long attachments.
* empty attachment causes divide by zero.
* distinction between multibyte and non-multibyte.
imho this just added complexity and maintainance headaches without
buying any useful performance.
* gratuitous usage of floating point.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: qp b64 patch --]
[-- Type: text/x-patch, Size: 1025 bytes --]
--- mm-encode.el- Tue Sep 21 17:41:18 1999
+++ mm-encode.el Tue Sep 21 17:51:29 1999
@@ -126,24 +126,17 @@
(defun mm-qp-or-base64 ()
(save-excursion
- (save-restriction
- (narrow-to-region (point-min) (min (+ (point-min) 1000) (point-max)))
+ (let ((limit (min (point-max) (+ 2000 (point-min))))
+ (n8bit 0))
(goto-char (point-min))
- (let ((8bit 0))
- (cond
- ((not (featurep 'mule))
- (while (re-search-forward "[^\x20-\x7f\r\n\t]" nil t)
- (incf 8bit)))
- (t
- ;; Mule version
- (while (not (eobp))
- (skip-chars-forward "\x20-\x7f\r\n\t")
- (unless (eobp)
- (forward-char 1)
- (incf 8bit)))))
- (if (> (/ (* 8bit 1.0) (buffer-size)) 0.166)
- 'base64
- 'quoted-printable)))))
+ (skip-chars-forward "\x20-\x7f\r\n\t" limit)
+ (while (< (point) limit)
+ (incf n8bit)
+ (forward-char 1)
+ (skip-chars-forward "\x20-\x7f\r\n\t" limit))
+ (if (< (* 6 n8bit) (- limit (point-min)))
+ 'quoted-printable
+ 'base64))))
(provide 'mm-encode)
[-- Attachment #3: Type: text/plain, Size: 84 bytes --]
--
J o h a n K u l l s t a m
[kullstam@ne.mediaone.net]
Don't Fear the Penguin!
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-09-21 22:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-21 22:07 [patch] fix of quoted-printable vs base64 chooser function Johan Kullstam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).