diff options
| author | Chong Yidong | 2008-09-25 00:05:52 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-09-25 00:05:52 +0000 |
| commit | 5273453b6833f87c852bee6b8b39a7658ba75490 (patch) | |
| tree | 33f464e91806294dd6ef3c305acd72fe39bf89bf | |
| parent | 1601aa7acf196ef3cca10f3bd4794eb4ad6950d5 (diff) | |
| download | emacs-5273453b6833f87c852bee6b8b39a7658ba75490.tar.gz emacs-5273453b6833f87c852bee6b8b39a7658ba75490.zip | |
(term-emulate-terminal): Encode input string before checking its
length.
| -rw-r--r-- | lisp/term.el | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/lisp/term.el b/lisp/term.el index e9dad90736c..a74e271f13a 100644 --- a/lisp/term.el +++ b/lisp/term.el | |||
| @@ -2718,7 +2718,11 @@ See `term-prompt-regexp'." | |||
| 2718 | 2718 | ||
| 2719 | (defun term-emulate-terminal (proc str) | 2719 | (defun term-emulate-terminal (proc str) |
| 2720 | (with-current-buffer (process-buffer proc) | 2720 | (with-current-buffer (process-buffer proc) |
| 2721 | (let* ((i 0) char funny count save-point save-marker old-point temp win | 2721 | (let* ((i 0) char funny |
| 2722 | count ; number of decoded chars in substring | ||
| 2723 | count-bytes ; number of bytes | ||
| 2724 | decoded-substring | ||
| 2725 | save-point save-marker old-point temp win | ||
| 2722 | (buffer-undo-list t) | 2726 | (buffer-undo-list t) |
| 2723 | (selected (selected-window)) | 2727 | (selected (selected-window)) |
| 2724 | last-win | 2728 | last-win |
| @@ -2777,6 +2781,10 @@ See `term-prompt-regexp'." | |||
| 2777 | str i)) | 2781 | str i)) |
| 2778 | (when (not funny) (setq funny str-length)) | 2782 | (when (not funny) (setq funny str-length)) |
| 2779 | (cond ((> funny i) | 2783 | (cond ((> funny i) |
| 2784 | (setq decoded-substring | ||
| 2785 | (decode-coding-string | ||
| 2786 | (substring str i funny) | ||
| 2787 | locale-coding-system)) | ||
| 2780 | (cond ((eq term-terminal-state 1) | 2788 | (cond ((eq term-terminal-state 1) |
| 2781 | ;; We are in state 1, we need to wrap | 2789 | ;; We are in state 1, we need to wrap |
| 2782 | ;; around. Go to the beginning of | 2790 | ;; around. Go to the beginning of |
| @@ -2785,21 +2793,31 @@ See `term-prompt-regexp'." | |||
| 2785 | (term-down 1 t) | 2793 | (term-down 1 t) |
| 2786 | (term-move-columns (- (term-current-column))) | 2794 | (term-move-columns (- (term-current-column))) |
| 2787 | (setq term-terminal-state 0))) | 2795 | (setq term-terminal-state 0))) |
| 2788 | (setq count (- funny i)) | 2796 | (setq count (length decoded-substring)) |
| 2789 | (setq temp (- (+ (term-horizontal-column) count) | 2797 | (setq temp (- (+ (term-horizontal-column) count) |
| 2790 | term-width)) | 2798 | term-width)) |
| 2791 | (cond ((<= temp 0)) ;; All count chars fit in line. | 2799 | (cond ((<= temp 0)) ;; All count chars fit in line. |
| 2792 | ((> count temp) ;; Some chars fit. | 2800 | ((> count temp) ;; Some chars fit. |
| 2793 | ;; This iteration, handle only what fits. | 2801 | ;; This iteration, handle only what fits. |
| 2794 | (setq count (- count temp)) | 2802 | (setq count (- count temp)) |
| 2803 | (setq count-bytes | ||
| 2804 | (length | ||
| 2805 | (encode-coding-string | ||
| 2806 | (substring decoded-substring 0 count) | ||
| 2807 | 'binary))) | ||
| 2795 | (setq temp 0) | 2808 | (setq temp 0) |
| 2796 | (setq funny (+ count i))) | 2809 | (setq funny (+ count-bytes i))) |
| 2797 | ((or (not (or term-pager-count | 2810 | ((or (not (or term-pager-count |
| 2798 | term-scroll-with-delete)) | 2811 | term-scroll-with-delete)) |
| 2799 | (> (term-handle-scroll 1) 0)) | 2812 | (> (term-handle-scroll 1) 0)) |
| 2800 | (term-adjust-current-row-cache 1) | 2813 | (term-adjust-current-row-cache 1) |
| 2801 | (setq count (min count term-width)) | 2814 | (setq count (min count term-width)) |
| 2802 | (setq funny (+ count i)) | 2815 | (setq count-bytes |
| 2816 | (length | ||
| 2817 | (encode-coding-string | ||
| 2818 | (substring decoded-substring 0 count) | ||
| 2819 | 'binary))) | ||
| 2820 | (setq funny (+ count-bytes i)) | ||
| 2803 | (setq term-start-line-column | 2821 | (setq term-start-line-column |
| 2804 | term-current-column)) | 2822 | term-current-column)) |
| 2805 | (t ;; Doing PAGER processing. | 2823 | (t ;; Doing PAGER processing. |
| @@ -2813,7 +2831,7 @@ See `term-prompt-regexp'." | |||
| 2813 | ;; following point if not eob nor insert-mode. | 2831 | ;; following point if not eob nor insert-mode. |
| 2814 | (let ((old-column (current-column)) | 2832 | (let ((old-column (current-column)) |
| 2815 | columns pos) | 2833 | columns pos) |
| 2816 | (insert (decode-coding-string (substring str i funny) locale-coding-system)) | 2834 | (insert decoded-substring) |
| 2817 | (setq term-current-column (current-column) | 2835 | (setq term-current-column (current-column) |
| 2818 | columns (- term-current-column old-column)) | 2836 | columns (- term-current-column old-column)) |
| 2819 | (when (not (or (eobp) term-insert-mode)) | 2837 | (when (not (or (eobp) term-insert-mode)) |