aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReuben Thomas2017-08-22 01:46:27 +0100
committerReuben Thomas2017-08-24 18:53:28 +0100
commitbd9ad2ea1051a73e30e720b90cf413ee93a977f7 (patch)
tree8546816a375a517987062c13c35cc7708036e45a
parent22ebde63c9df6a6815359c1e3406baddec1ed55b (diff)
downloademacs-bd9ad2ea1051a73e30e720b90cf413ee93a977f7.tar.gz
emacs-bd9ad2ea1051a73e30e720b90cf413ee93a977f7.zip
Avoid using string-to-multibyte in ispell.el
* lisp/textmodes/ispell.el (ispell-get-decoded-string): Use decode-coding-string instead. Note that decode-coding-string returns a string that satisfies multibyte-string-p even if its input is pure ASCII and the third argument is t, so the result of ispell-get-decoded-string is always a multibyte string.
-rw-r--r--lisp/textmodes/ispell.el16
1 files changed, 3 insertions, 13 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index e67e603e990..87a3b7aaa12 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1485,25 +1485,15 @@ used as key in `ispell-local-dictionary-alist' and `ispell-dictionary-alist'.")
1485 "The name of the current personal dictionary, or nil for the default. 1485 "The name of the current personal dictionary, or nil for the default.
1486This is passed to the Ispell process using the `-p' switch.") 1486This is passed to the Ispell process using the `-p' switch.")
1487 1487
1488(defun ispell-decode-string (str)
1489 "Decodes multibyte character strings."
1490 (decode-coding-string str (ispell-get-coding-system)))
1491
1492;; Return a string decoded from Nth element of the current dictionary. 1488;; Return a string decoded from Nth element of the current dictionary.
1493(defun ispell-get-decoded-string (n) 1489(defun ispell-get-decoded-string (n)
1494 "Get the decoded string in slot N of the descriptor of the current dict." 1490 "Get the decoded string in slot N of the descriptor of the current dict."
1495 (let* ((slot (or 1491 (let* ((slot (or
1496 (assoc ispell-current-dictionary ispell-local-dictionary-alist) 1492 (assoc ispell-current-dictionary ispell-local-dictionary-alist)
1497 (assoc ispell-current-dictionary ispell-dictionary-alist) 1493 (assoc ispell-current-dictionary ispell-dictionary-alist)
1498 (error "No data for dictionary \"%s\", neither in `ispell-local-dictionary-alist' nor in `ispell-dictionary-alist'" 1494 (error "No data for dictionary \"%s\" in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'"
1499 ispell-current-dictionary))) 1495 ispell-current-dictionary))))
1500 (str (nth n slot))) 1496 (decode-coding-string (nth n slot) (ispell-get-coding-system) t)))
1501 (when (and (> (length str) 0)
1502 (not (multibyte-string-p str)))
1503 (setq str (ispell-decode-string str))
1504 (or (multibyte-string-p str)
1505 (setq str (string-to-multibyte str))))
1506 str))
1507 1497
1508(defun ispell-get-casechars () 1498(defun ispell-get-casechars ()
1509 (ispell-get-decoded-string 1)) 1499 (ispell-get-decoded-string 1))