Gnus development mailing list
 help / color / mirror / Atom feed
From: "Johan Kullstam" <kullstam@ne.mediaone.net>
Subject: [patch] fix of quoted-printable vs base64 chooser function
Date: 21 Sep 1999 18:07:10 -0400	[thread overview]
Message-ID: <m267135375.fsf@sophia.axel.nom> (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!

                 reply	other threads:[~1999-09-21 22:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m267135375.fsf@sophia.axel.nom \
    --to=kullstam@ne.mediaone.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).