Fix 'uudecode-decode-region-internal' in multibyte buffers
* lisp/mail/uudecode.el (uudecode-decode-region-internal): Fix inserting the decoded string into a multibyte buffer. Optimize by working with characters, not strings. (Bug#44411) Copyright-paperwork-exempt: yes
This commit is contained in:
parent
d4242177da
commit
f5d7fb3a2d
1 changed files with 17 additions and 19 deletions
|
@ -162,12 +162,10 @@ If FILE-NAME is non-nil, save the result to FILE-NAME."
|
||||||
(setq counter (1+ counter)
|
(setq counter (1+ counter)
|
||||||
inputpos (1+ inputpos))
|
inputpos (1+ inputpos))
|
||||||
(cond ((= counter 4)
|
(cond ((= counter 4)
|
||||||
(setq result (cons
|
(setq result (cons (logand bits 255)
|
||||||
(concat
|
(cons (logand (ash bits -8) 255)
|
||||||
(char-to-string (ash bits -16))
|
(cons (ash bits -16)
|
||||||
(char-to-string (logand (ash bits -8) 255))
|
result))))
|
||||||
(char-to-string (logand bits 255)))
|
|
||||||
result))
|
|
||||||
(setq bits 0 counter 0))
|
(setq bits 0 counter 0))
|
||||||
(t (setq bits (ash bits 6)))))))
|
(t (setq bits (ash bits 6)))))))
|
||||||
(cond
|
(cond
|
||||||
|
@ -179,26 +177,26 @@ If FILE-NAME is non-nil, save the result to FILE-NAME."
|
||||||
;;(error "uucode ends unexpectedly")
|
;;(error "uucode ends unexpectedly")
|
||||||
(setq done t))
|
(setq done t))
|
||||||
((= counter 3)
|
((= counter 3)
|
||||||
(setq result (cons
|
(setq result (cons (logand (ash bits -8) 255)
|
||||||
(concat
|
(cons (logand (ash bits -16) 255)
|
||||||
(char-to-string (logand (ash bits -16) 255))
|
result))))
|
||||||
(char-to-string (logand (ash bits -8) 255)))
|
|
||||||
result)))
|
|
||||||
((= counter 2)
|
((= counter 2)
|
||||||
(setq result (cons
|
(setq result (cons (logand (ash bits -10) 255)
|
||||||
(char-to-string (logand (ash bits -10) 255))
|
|
||||||
result))))
|
result))))
|
||||||
(skip-chars-forward non-data-chars end))
|
(skip-chars-forward non-data-chars end))
|
||||||
(if file-name
|
(if file-name
|
||||||
(with-temp-file file-name
|
(with-temp-file file-name
|
||||||
(set-buffer-multibyte nil)
|
(set-buffer-multibyte nil)
|
||||||
(insert (apply #'concat (nreverse result))))
|
(apply #'insert (nreverse result)))
|
||||||
(or (markerp end) (setq end (set-marker (make-marker) end)))
|
(or (markerp end) (setq end (set-marker (make-marker) end)))
|
||||||
(goto-char start)
|
(goto-char start)
|
||||||
|
(apply #'insert
|
||||||
|
(nreverse
|
||||||
(if enable-multibyte-characters
|
(if enable-multibyte-characters
|
||||||
(dolist (x (nreverse result))
|
(mapcar (lambda (ch)
|
||||||
(insert (decode-coding-string x 'binary)))
|
(or (decode-char 'eight-bit ch) ch))
|
||||||
(insert (apply #'concat (nreverse result))))
|
result)
|
||||||
|
result)))
|
||||||
(delete-region (point) end))))))
|
(delete-region (point) end))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
Loading…
Add table
Reference in a new issue