From: morioka Date: Wed, 16 Sep 1998 01:47:04 +0000 (+0000) Subject: rearrangement. X-Git-Tag: flim-1_10_0-pre1~13 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f4472ce3a34e1a9503df5c83fdbf10c387be821;p=elisp%2Fflim.git rearrangement. --- diff --git a/mel-b.el b/mel-b.el index e41535a..9df9aa3 100644 --- a/mel-b.el +++ b/mel-b.el @@ -67,67 +67,6 @@ external decoder is called." :type 'integer) -;;; @ internal base64 decoder -;;; - -(defconst base64-numbers - [nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil - nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil - nil nil nil nil nil nil nil nil nil nil nil 62 nil nil nil 63 - 52 53 54 55 56 57 58 59 60 61 nil nil nil nil nil nil - nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 - 15 16 17 18 19 20 21 22 23 24 25 nil nil nil nil nil - nil 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 - 41 42 43 44 45 46 47 48 49 50 51]) - -(defmacro base64-char-to-num (c) - `(aref base64-numbers ,c)) - -(defsubst base64-internal-decode (string buffer) - (let* ((len (length string)) - (i 0) - (j 0) - v1 v2 v3) - (catch 'tag - (while (< i len) - (when (prog1 (setq v1 (base64-char-to-num (aref string i))) - (setq i (1+ i))) - (setq v2 (base64-char-to-num (aref string i)) - i (1+ i) - v3 (base64-char-to-num (aref string i)) - i (1+ i)) - (aset buffer j (logior (lsh v1 2)(lsh v2 -4))) - (setq j (1+ j)) - (if v3 - (let ((v4 (base64-char-to-num (aref string i)))) - (setq i (1+ i)) - (aset buffer j (logior (lsh (logand v2 15) 4)(lsh v3 -2))) - (setq j (1+ j)) - (if v4 - (aset buffer (prog1 j (setq j (1+ j))) - (logior (logand (lsh (logand v3 15) 6) 255) - v4)) - (throw 'tag nil) - )) - (throw 'tag nil) - )))) - (substring buffer 0 j) - )) - -(defun base64-internal-decode-string (string) - (base64-internal-decode string (make-string (length string) 0))) - -(defsubst base64-internal-decode-string! (string) - (base64-internal-decode string string)) - -(defun base64-internal-decode-region (beg end) - (save-excursion - (let ((str (buffer-substring beg end))) - (delete-region beg end) - (goto-char beg) - (insert (base64-internal-decode-string! str))))) - - ;;; @ internal base64 encoder ;;; based on base64 decoder by Enami Tsugutomo @@ -205,6 +144,67 @@ external decoder is called." ))) +;;; @ internal base64 decoder +;;; + +(defconst base64-numbers + [nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil + nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil + nil nil nil nil nil nil nil nil nil nil nil 62 nil nil nil 63 + 52 53 54 55 56 57 58 59 60 61 nil nil nil nil nil nil + nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + 15 16 17 18 19 20 21 22 23 24 25 nil nil nil nil nil + nil 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 + 41 42 43 44 45 46 47 48 49 50 51]) + +(defmacro base64-char-to-num (c) + `(aref base64-numbers ,c)) + +(defsubst base64-internal-decode (string buffer) + (let* ((len (length string)) + (i 0) + (j 0) + v1 v2 v3) + (catch 'tag + (while (< i len) + (when (prog1 (setq v1 (base64-char-to-num (aref string i))) + (setq i (1+ i))) + (setq v2 (base64-char-to-num (aref string i)) + i (1+ i) + v3 (base64-char-to-num (aref string i)) + i (1+ i)) + (aset buffer j (logior (lsh v1 2)(lsh v2 -4))) + (setq j (1+ j)) + (if v3 + (let ((v4 (base64-char-to-num (aref string i)))) + (setq i (1+ i)) + (aset buffer j (logior (lsh (logand v2 15) 4)(lsh v3 -2))) + (setq j (1+ j)) + (if v4 + (aset buffer (prog1 j (setq j (1+ j))) + (logior (logand (lsh (logand v3 15) 6) 255) + v4)) + (throw 'tag nil) + )) + (throw 'tag nil) + )))) + (substring buffer 0 j) + )) + +(defun base64-internal-decode-string (string) + (base64-internal-decode string (make-string (length string) 0))) + +(defsubst base64-internal-decode-string! (string) + (base64-internal-decode string string)) + +(defun base64-internal-decode-region (beg end) + (save-excursion + (let ((str (buffer-substring beg end))) + (delete-region beg end) + (goto-char beg) + (insert (base64-internal-decode-string! str))))) + + ;;; @ base64 encoder/decoder for region ;;;