Subject: Fix use of string-to-multibyte in ispell.el
From: Reuben Thomas <[email-masked]>
To: bug-emacs <[email-masked]>
Date: Tue, 22 Aug 2017 01:51:53 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

The attached patch removes a use of string-to-multibyte in ispell.el.

It turned out to be possible to simplify the surrounding code quite a
bit too.

-- 
https://rrt.sc3d.org
From 077584030546f97c06d1f8c907475a04115e6c58 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Tue, 22 Aug 2017 01:46:27 +0100
Subject: [PATCH] Avoid using string-to-multibyte in ispell.el

* lisp/textmodes/ispell.el (ispell-get-decoded-string): Use
decode-coding-string instead.
---
 lisp/textmodes/ispell.el | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index e67e603..87a3b7a 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1485,25 +1485,15 @@ ispell-current-personal-dictionary
   "The name of the current personal dictionary, or nil for the default.
 This is passed to the Ispell process using the `-p' switch.")
 
-(defun ispell-decode-string (str)
-  "Decodes multibyte character strings."
-  (decode-coding-string str (ispell-get-coding-system)))
-
 ;; Return a string decoded from Nth element of the current dictionary.
 (defun ispell-get-decoded-string (n)
   "Get the decoded string in slot N of the descriptor of the current dict."
   (let* ((slot (or
 		(assoc ispell-current-dictionary ispell-local-dictionary-alist)
 		(assoc ispell-current-dictionary ispell-dictionary-alist)
-		(error "No data for dictionary \"%s\", neither in `ispell-local-dictionary-alist' nor in `ispell-dictionary-alist'"
-		       ispell-current-dictionary)))
-	 (str (nth n slot)))
-    (when (and (> (length str) 0)
-	       (not (multibyte-string-p str)))
-      (setq str (ispell-decode-string str))
-      (or (multibyte-string-p str)
-	  (setq str (string-to-multibyte str))))
-    str))
+		(error "No data for dictionary \"%s\" in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'"
+		       ispell-current-dictionary))))
+    (decode-coding-string (nth n slot) (ispell-get-coding-system) t)))
 
 (defun ispell-get-casechars ()
   (ispell-get-decoded-string 1))
-- 
2.7.4