diff options
| author | Dave Love | 2000-11-01 14:46:55 +0000 |
|---|---|---|
| committer | Dave Love | 2000-11-01 14:46:55 +0000 |
| commit | dd8955f010bec28b040388b288349834fe9b038a (patch) | |
| tree | c0b51e7c4f9a3844fecf0f7b56707c2ca20ed34c | |
| parent | cd66d2ed41e603162041ee546caf692f548800c9 (diff) | |
| download | emacs-dd8955f010bec28b040388b288349834fe9b038a.tar.gz emacs-dd8955f010bec28b040388b288349834fe9b038a.zip | |
Use (featurep 'xemacs).
(binhex-char-int): New alias, replacing char-int.
Change callers.
(binhex-decode-region): Simplify work buffer code.
(binhex-decode-region-external): Use expand-file-name, not concat.
| -rw-r--r-- | lisp/gnus/binhex.el | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/lisp/gnus/binhex.el b/lisp/gnus/binhex.el index 200d571a4b0..1b096287240 100644 --- a/lisp/gnus/binhex.el +++ b/lisp/gnus/binhex.el | |||
| @@ -28,8 +28,10 @@ | |||
| 28 | 28 | ||
| 29 | (eval-when-compile (require 'cl)) | 29 | (eval-when-compile (require 'cl)) |
| 30 | 30 | ||
| 31 | (if (not (fboundp 'char-int)) | 31 | (defalias 'binhex-char-int |
| 32 | (fset 'char-int 'identity)) | 32 | (if (fboundp 'char-int) |
| 33 | 'char-int | ||
| 34 | 'identity)) | ||
| 33 | 35 | ||
| 34 | (defvar binhex-decoder-program "hexbin" | 36 | (defvar binhex-decoder-program "hexbin" |
| 35 | "*Non-nil value should be a string that names a uu decoder. | 37 | "*Non-nil value should be a string that names a uu decoder. |
| @@ -67,7 +69,7 @@ input and write the converted data to its standard output.") | |||
| 67 | ((boundp 'temporary-file-directory) temporary-file-directory) | 69 | ((boundp 'temporary-file-directory) temporary-file-directory) |
| 68 | ("/tmp/"))) | 70 | ("/tmp/"))) |
| 69 | 71 | ||
| 70 | (if (string-match "XEmacs" emacs-version) | 72 | (if (featurep 'xemacs) |
| 71 | (defalias 'binhex-insert-char 'insert-char) | 73 | (defalias 'binhex-insert-char 'insert-char) |
| 72 | (defun binhex-insert-char (char &optional count ignored buffer) | 74 | (defun binhex-insert-char (char &optional count ignored buffer) |
| 73 | (if (or (null buffer) (eq buffer (current-buffer))) | 75 | (if (or (null buffer) (eq buffer (current-buffer))) |
| @@ -132,14 +134,14 @@ input and write the converted data to its standard output.") | |||
| 132 | (defun binhex-string-big-endian (string) | 134 | (defun binhex-string-big-endian (string) |
| 133 | (let ((ret 0) (i 0) (len (length string))) | 135 | (let ((ret 0) (i 0) (len (length string))) |
| 134 | (while (< i len) | 136 | (while (< i len) |
| 135 | (setq ret (+ (lsh ret 8) (char-int (aref string i))) | 137 | (setq ret (+ (lsh ret 8) (binhex-char-int (aref string i))) |
| 136 | i (1+ i))) | 138 | i (1+ i))) |
| 137 | ret)) | 139 | ret)) |
| 138 | 140 | ||
| 139 | (defun binhex-string-little-endian (string) | 141 | (defun binhex-string-little-endian (string) |
| 140 | (let ((ret 0) (i 0) (shift 0) (len (length string))) | 142 | (let ((ret 0) (i 0) (shift 0) (len (length string))) |
| 141 | (while (< i len) | 143 | (while (< i len) |
| 142 | (setq ret (+ ret (lsh (char-int (aref string i)) shift)) | 144 | (setq ret (+ ret (lsh (binhex-char-int (aref string i)) shift)) |
| 143 | i (1+ i) | 145 | i (1+ i) |
| 144 | shift (+ shift 8))) | 146 | shift (+ shift 8))) |
| 145 | ret)) | 147 | ret)) |
| @@ -149,11 +151,11 @@ input and write the converted data to its standard output.") | |||
| 149 | (let ((pos (point-min)) len) | 151 | (let ((pos (point-min)) len) |
| 150 | (vector | 152 | (vector |
| 151 | (prog1 | 153 | (prog1 |
| 152 | (setq len (char-int (char-after pos))) | 154 | (setq len (binhex-char-int (char-after pos))) |
| 153 | (setq pos (1+ pos))) | 155 | (setq pos (1+ pos))) |
| 154 | (buffer-substring pos (setq pos (+ pos len))) | 156 | (buffer-substring pos (setq pos (+ pos len))) |
| 155 | (prog1 | 157 | (prog1 |
| 156 | (setq len (char-int (char-after pos))) | 158 | (setq len (binhex-char-int (char-after pos))) |
| 157 | (setq pos (1+ pos))) | 159 | (setq pos (1+ pos))) |
| 158 | (buffer-substring pos (setq pos (+ pos 4))) | 160 | (buffer-substring pos (setq pos (+ pos 4))) |
| 159 | (buffer-substring pos (setq pos (+ pos 4))) | 161 | (buffer-substring pos (setq pos (+ pos 4))) |
| @@ -198,15 +200,8 @@ If HEADER-ONLY is non-nil only decode header and return filename." | |||
| 198 | (save-excursion | 200 | (save-excursion |
| 199 | (goto-char start) | 201 | (goto-char start) |
| 200 | (when (re-search-forward binhex-begin-line end t) | 202 | (when (re-search-forward binhex-begin-line end t) |
| 201 | (if (and (not (string-match "XEmacs\\|Lucid" emacs-version)) | 203 | (let (default-enable-multibyte-characters) |
| 202 | (boundp 'enable-multibyte-characters)) | ||
| 203 | (let ((multibyte | ||
| 204 | (default-value 'enable-multibyte-characters))) | ||
| 205 | (setq-default enable-multibyte-characters nil) | ||
| 206 | (setq work-buffer (generate-new-buffer " *binhex-work*")) | ||
| 207 | (setq-default enable-multibyte-characters multibyte)) | ||
| 208 | (setq work-buffer (generate-new-buffer " *binhex-work*"))) | 204 | (setq work-buffer (generate-new-buffer " *binhex-work*"))) |
| 209 | (buffer-disable-undo work-buffer) | ||
| 210 | (beginning-of-line) | 205 | (beginning-of-line) |
| 211 | (setq bits 0 counter 0) | 206 | (setq bits 0 counter 0) |
| 212 | (while tmp | 207 | (while tmp |
| @@ -267,9 +262,9 @@ If HEADER-ONLY is non-nil only decode header and return filename." | |||
| 267 | "Binhex decode region between START and END using external decoder." | 262 | "Binhex decode region between START and END using external decoder." |
| 268 | (interactive "r") | 263 | (interactive "r") |
| 269 | (let ((cbuf (current-buffer)) firstline work-buffer status | 264 | (let ((cbuf (current-buffer)) firstline work-buffer status |
| 270 | (file-name (concat binhex-temporary-file-directory | 265 | (file-name (expand-file-name |
| 271 | (binhex-decode-region start end t) | 266 | (concat (binhex-decode-region start end t) ".data") |
| 272 | ".data"))) | 267 | binhex-temporary-file-directory))) |
| 273 | (save-excursion | 268 | (save-excursion |
| 274 | (goto-char start) | 269 | (goto-char start) |
| 275 | (when (re-search-forward binhex-begin-line nil t) | 270 | (when (re-search-forward binhex-begin-line nil t) |