changeset 62795:9b285ff39db2

Don't register a coding system into non-iso-charset-alist more than once. (cp-make-coding-system): Likewise.
author Kenichi Handa <handa@m17n.org>
date Fri, 27 May 2005 11:20:16 +0000
parents 5164b4f6be8f
children bd02ca99bb04
files lisp/international/code-pages.el
diffstat 1 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/code-pages.el	Fri May 27 11:02:11 2005 +0000
+++ b/lisp/international/code-pages.el	Fri May 27 11:20:16 2005 +0000
@@ -193,15 +193,18 @@
 	      ;; a separate table that only translates the coding
 	      ;; system's safe-chars.
 	      (cons 'translation-table-for-input 'ucs-mule-to-mule-unicode)))
-       (push (list ',name
-		   nil			; charset list
-		   ',decoder
-		   (let (l)		; code range
-		     (dolist (elt (reverse codes))
-		       (push (cdr elt) l)
-		       (push (car elt) l))
-		     (list l)))
-	     non-iso-charset-alist))))
+       (let ((slot (assq ',name non-iso-charset-alist))
+	     (elt (list nil			; charset list
+			',decoder
+			(let (l)		; code range
+			  (dolist (elt (reverse codes))
+			    (push (cdr elt) l)
+			    (push (car elt) l))
+			  (list l)))))
+	 (if (not slot)
+	     (push (cons ',name elt) non-iso-charset-alist)
+	   (setcdr slot elt)
+	   non-iso-charset-alist)))))
 
 (eval-when-compile (defvar non-iso-charset-alist))
 
@@ -4502,11 +4505,14 @@
     ;; Define cp125* as aliases for all windows-125*, so on Windows
     ;; we can just concat "cp" to the ANSI codepage we get from the system
     ;; and not have to worry about whether it should be "cp" or "windows-".
-    (if (coding-system-p w)
-	(define-coding-system-alias c w))
-    ;; Compatibility with codepage.el, though cp... are not the
-    ;; canonical names.
-    (push (assoc w non-iso-charset-alist) non-iso-charset-alist)))
+    (when (coding-system-p w)
+      (define-coding-system-alias c w)
+      ;; Compatibility with codepage.el, though cp... are not the
+      ;; canonical names.
+      (if (not (assq c non-iso-charset-alist))
+	  (let ((slot (assq w non-iso-charset-alist)))
+	    (if slot
+		(push (cons c (cdr slot)) non-iso-charset-alist)))))))
 
 (provide 'code-pages)