aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2002-03-01 02:07:18 +0000
committerKenichi Handa2002-03-01 02:07:18 +0000
commit9617ce06760605c25322af89e5a706e8ff3faacb (patch)
tree0829ded04fc62cebc784470a3d8f8a352a5fcfee
parent55bd52ea72a8ac065e9beba6080ee9214cf7b582 (diff)
downloademacs-9617ce06760605c25322af89e5a706e8ff3faacb.tar.gz
emacs-9617ce06760605c25322af89e5a706e8ff3faacb.zip
(cp-make-translation-table,
cp-valid-codes, cp-fix-safe-chars): Deleted. Caller changed. (cp-make-coding-system): Call define-coding-system.
-rw-r--r--lisp/international/code-pages.el115
1 files changed, 24 insertions, 91 deletions
diff --git a/lisp/international/code-pages.el b/lisp/international/code-pages.el
index 90a10e92b57..866c2c524b6 100644
--- a/lisp/international/code-pages.el
+++ b/lisp/international/code-pages.el
@@ -55,57 +55,10 @@
55 55
56;;; Code: 56;;; Code:
57 57
58(defun cp-make-translation-table (v)
59 "Return a translation table made from 128-long vector V.
60V comprises characters encodable by mule-utf-8."
61 (let ((encoding-vector (make-vector 256 0)))
62 (dotimes (i 128)
63 (aset encoding-vector i i))
64 (dotimes (i 128)
65 (aset encoding-vector (+ i 128) (aref v i)))
66 (make-translation-table-from-vector encoding-vector)))
67
68(defun cp-valid-codes (v)
69 "Derive a valid-codes list for translation vector V.
70See `make-coding-system'."
71 (let (pairs
72 (i 128) ; index into v
73 (start 0) ; start of a valid range
74 (end 127)) ; end of a valid range
75 (while (< i 256)
76 (if (aref v (- i 128)) ; start or extend range
77 (progn
78 (setq end i)
79 (unless start (setq start i)))
80 (if start
81 (push (cons start end) pairs))
82 (setq start nil))
83 (setq i (1+ i)))
84 (if start (push (cons start end) pairs))
85 (nreverse pairs)))
86
87(defun cp-fix-safe-chars (cs)
88 "Remove `char-coding-system-table' entries from previous definition of CS.
89CS is a base coding system or alias."
90 (when (coding-system-p cs)
91 (let ((chars (coding-system-get cs 'safe-chars)))
92 (map-char-table
93 (lambda (k v)
94 (if (and v (not (eq v t)))
95 (aset char-coding-system-table
96 k
97 (remq cs (aref char-coding-system-table v)))))
98 chars))))
99
100;; Fix things that have been, or might be done by codepage.el. 58;; Fix things that have been, or might be done by codepage.el.
101(eval-after-load "codepage" 59(eval-after-load "codepage"
102 '(progn 60 '(progn
103 61
104 (dolist (cs '(cp857 cp861 cp1253 cp852 cp866 cp437 cp855 cp869 cp775
105 cp862 cp864 cp1250 cp863 cp865 cp1251 cp737 cp1257 cp850
106 cp860 cp851 720))
107 (cp-fix-safe-chars cs))
108
109;; Semi-dummy version for the stuff in codepage.el which we don't 62;; Semi-dummy version for the stuff in codepage.el which we don't
110;; define here. (Used by mule-diag.) 63;; define here. (Used by mule-diag.)
111(defun cp-supported-codepages () 64(defun cp-supported-codepages ()
@@ -170,50 +123,30 @@ V is a 128-long vector of characters to translate the upper half of
170the charactert set. DOC-STRING and MNEMONIC are used as the 123the charactert set. DOC-STRING and MNEMONIC are used as the
171corresponding args of `make-coding-system'. If MNEMONIC isn't given, 124corresponding args of `make-coding-system'. If MNEMONIC isn't given,
172?* is used." 125?* is used."
173 (let* ((encoder (intern (format "encode-%s" name))) 126 `(progn
174 (decoder (intern (format "decode-%s" name))) 127 (define-charset ',name ""
175 (ccl-decoder 128 :dimension 1
176 (ccl-compile 129 :code-space [ 0 255 ]
177 `(4 130 :ascii-compatible-p t
178 ((loop 131 :map ,(let ((len 0)
179 (read r1) 132 map)
180 (if (r1 < 128) ;; ASCII 133 (dotimes (i 128)
181 (r0 = ,(charset-id 'ascii)) 134 (if (aref v i) (setq len (1+ len))))
182 (if (r1 < 160) 135 (setq map (make-vector (* len 2) nil))
183 (r0 = ,(charset-id 'eight-bit-control)) 136 (setq len 0)
184 (r0 = ,(charset-id 'eight-bit-graphic)))) 137 (dotimes (i 128)
185 (translate-character ,decoder r0 r1) 138 (when (aref v i)
186 (write-multibyte-character r0 r1) 139 (aset map len (+ 128 i))
187 (repeat)))))) 140 (aset map (1+ len) (aref v i))
188 (ccl-encoder 141 (setq len (+ len 2))))
189 (ccl-compile 142 map))
190 `(1 143
191 ((loop 144 (define-coding-system ',name
192 (read-multibyte-character r0 r1) 145 ,(or doc-string "")
193 (translate-character ,encoder r0 r1) 146 :coding-type 'charset
194 (write-repeat r1))))))) 147 :mnemonic ,(or mnemonic ?*)
195 `(let ((translation-table (cp-make-translation-table ,v)) 148 :charset-list '(,name)
196 (codes (cp-valid-codes ,v))) 149 :plist '(mime-charset ,name))))
197 (define-translation-table ',decoder translation-table)
198 (define-translation-table ',encoder
199 (char-table-extra-slot translation-table 0))
200 (cp-fix-safe-chars ',name)
201 (make-coding-system
202 ',name 4 ,(or mnemonic ?*)
203 (or ,doc-string (format "%s encoding" ',name))
204 (cons ,ccl-decoder ,ccl-encoder)
205 (list (cons 'safe-chars (get ',encoder 'translation-table))
206 (cons 'valid-codes codes)
207 (cons 'mime-charset ',name)))
208 (push (list ',name
209 nil ; charset list
210 ',decoder
211 (let (l) ; code range
212 (dolist (elt (reverse codes))
213 (push (cdr elt) l)
214 (push (car elt) l))
215 (list l)))
216 non-iso-charset-alist))))
217 150
218 151
219;; These tables were mostly derived by running somthing like 152;; These tables were mostly derived by running somthing like