From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/25184 Path: main.gmane.org!not-for-mail From: "Johan Kullstam" Newsgroups: gmane.emacs.gnus.general Subject: [patch] fix of quoted-printable vs base64 chooser function Date: 21 Sep 1999 18:07:10 -0400 Organization: none Sender: owner-ding@hpc.uh.edu Message-ID: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1035162617 12692 80.91.224.250 (21 Oct 2002 01:10:17 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 01:10:17 +0000 (UTC) Return-Path: Original-Received: from bart.math.uh.edu (bart.math.uh.edu [129.7.128.48]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id SAA22610 for ; Tue, 21 Sep 1999 18:07:28 -0400 (EDT) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by bart.math.uh.edu (8.9.1/8.9.1) with ESMTP id RAB12729; Tue, 21 Sep 1999 17:07:22 -0500 (CDT) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Tue, 21 Sep 1999 17:07:28 -0500 (CDT) Original-Received: from sclp3.sclp.com (root@sclp3.sclp.com [204.252.123.139]) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id RAA16603 for ; Tue, 21 Sep 1999 17:07:17 -0500 (CDT) Original-Received: from kullstam.ne.mediaone.net (qmailr@kullstam.ne.mediaone.net [24.218.92.14]) by sclp3.sclp.com (8.8.5/8.8.5) with SMTP id SAA22587 for ; Tue, 21 Sep 1999 18:05:10 -0400 (EDT) Original-Received: (qmail 21864 invoked by uid 501); 21 Sep 1999 22:07:11 -0000 Original-To: ding@gnus.org Original-Lines: 45 User-Agent: Gnus/5.070096 (Pterodactyl Gnus v0.96) Emacs/20.4 Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:25184 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:25184 --=-=-= 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=mm-encode.el.patch Content-Description: qp b64 patch --- 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) --=-=-= -- J o h a n K u l l s t a m [kullstam@ne.mediaone.net] Don't Fear the Penguin! --=-=-=--