Commit 776ca83d authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files


Create separate encoders and decoders, for DOS and Unix.  Make the
usual family of 3 coding systems, so that automatic detection of
EOL type works.
(cp-make-coding-systems-for-codepage): Don't intern DOS- and
Unix-specific symbols here, and don't call
cp-coding-system-for-codepage-1 twice.  (Suggested by Ken'ichi
Handa <>.)
parent 9d45accd
......@@ -52,25 +52,11 @@ encoding to Emacs multibyte characters.
ENCODER is a translation table for encoding Emacs multibyte characters into
external DOS codepage codes.
Note that the coding systems created by this function don't support
automatic detection of the EOL format. Use explicit -dos or -unix variants
as appropriate (Mac EOL style is not supported, as it doesn't make sense for
these coding systems).
If the coding system's name ends with \"-dos\", this function automatically
creates a coding system which converts from and to DOS EOL format; otherwise
the created coding system assumes Unix-style EOL (i.e., it doesn't perform
any EOL conversions)."
Note that the coding systems created by this function support automatic
detection of the EOL format."
(let* ((coding-name (symbol-name coding))
(eol-type (string-match "-\\(dos\\|unix\\)\\'" coding-name))
(and eol-type
(string= "-dos" (substring coding-name eol-type))))
(if eol-type (substring coding-name 0 eol-type) coding-name))
(if dos-p
`(4 (loop (read r1)
(if (r1 != ?\r)
......@@ -81,7 +67,8 @@ any EOL conversions)."
(write r1)
(write-multibyte-character r0 r1)))
(write r1)))
`(4 (loop (read r1)
(if (r1 >= 128)
......@@ -91,9 +78,8 @@ any EOL conversions)."
(write r1)
(write-multibyte-character r0 r1)))
(write r1))
(if dos-p
`(1 (loop (read-multibyte-character r0 r1)
(if (r1 == ?\n)
......@@ -103,7 +89,8 @@ any EOL conversions)."
(if (r0 == ,(charset-id 'japanese-jisx0208))
((r1 = ??)
(write r1))))))
(write-repeat r1))))
(write-repeat r1)))))
`(1 (loop (read-multibyte-character r0 r1)
(if (r0 != ,(charset-id 'ascii))
......@@ -111,16 +98,33 @@ any EOL conversions)."
(if (r0 == ,(charset-id 'japanese-jisx0208))
((r1 = ??)
(write r1)))))
(write-repeat r1)))))))
(write-repeat r1))))))
(if (memq coding coding-system-list)
(setq coding-system-list (delq coding coding-system-list)))
;; Make coding system CODING.
coding 4 mnemonic
(concat "8-bit encoding of " (symbol-name iso-name)
" characters using IBM codepage " (substring coding-sans-eol 2))
(cons ccl-decoder ccl-encoder)
" characters using IBM codepage " coding-name)
(cons ccl-decoder-unix ccl-encoder-unix)
`((safe-charsets ascii ,iso-name)))
(put coding 'eol-type (if dos-p 1 0)))))
;;; Make coding systems CODING-unix, CODING-dos, CODING-mac.
(make-subsidiary-coding-system coding)
(put coding 'eol-type (vector (intern (format "%s-unix" coding))
(intern (format "%s-dos" coding))
(intern (format "%s-mac" coding))))
;; Change CCL code for CODING-dos.
(let ((coding-spec (copy-sequence (get coding 'coding-system))))
(aset coding-spec 4
(cons (check-ccl-program
(intern (format "%s-dos-decoder" coding)))
(intern (format "%s-dos-encoder" coding)))))
(put (intern (concat coding-name "-dos")) 'coding-system
(defun cp-decoding-vector-for-codepage (table charset offset)
"Create a vector for decoding IBM PC characters using conversion table
......@@ -418,11 +422,7 @@ perform any EOL conversions."
(intern (format "%s-decode-translation-table" codepage)))
(intern (format "%s-encode-translation-table" codepage)))
(intern (format "%s-dos" codepage)))
(intern (format "%s-unix" codepage))))
(intern (format "%s-encode-translation-table" codepage))))
(set nonascii-table
......@@ -444,9 +444,8 @@ perform any EOL conversions."
(define-translation-table decode-translation
(symbol-value nonascii-table))
codepage-dos ?D iso-name decode-translation encode-translation)
codepage-unix ?D iso-name decode-translation encode-translation)))
(intern codepage) ?D iso-name decode-translation encode-translation)
(defun cp-codepage-decoder (codepage)
"If CODEPAGE is the name of a supported codepage, return its decode table;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment