SUPERSEDES APPROVE COMMIT 21.5
Because the query function and the mutator are from different APIs,
they actually use different symbols to indicate the same subsidiary
coding system. So the logic to decide which coding system to return
only worked in the case of nil!
Apply with patch -p1.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 86e6e6c..baa79ba 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -0,0 +1,6 @@
+2006-05-23 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * code-cmds.el: Update FSF copyright; improve header comment.
+ (coding-system-change-eol-conversion): Clarify, add sanity check.
+ Fix keyword mismatch between function arg and subsidiary accessor.
+
diff --git a/lisp/code-cmds.el b/lisp/code-cmds.el
index f369ce2..754851e 100644
--- a/lisp/code-cmds.el
+++ b/lisp/code-cmds.el
@@ -2,7 +2,7 @@
;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
;; Licensed to the Free Software Foundation.
-;; Copyright (C) 2000 Free Software Foundation
+;; Copyright (C) 2000,2006 Free Software Foundation
;; Copyright (C) 1997 MORIOKA Tomohiko
;; Copyright (C) 2001, 2002 Ben Wing.
@@ -27,8 +27,8 @@
;;
;; This code defines the keybindings and utility commands for the
;; user to manipulate coding systems.
-;; This code used to be in mule-cmds.el which now only needs the
-;; additional bindings/commands that are avaible on the real mule.
+;; This code used to be in mule-cmds.el which now contains only the
+;; additional bindings/commands that are available for full Mule.
;;; Code:
@@ -53,41 +53,36 @@
(define-key coding-keymap "x" 'set-selection-coding-system)
(define-key coding-keymap "X" 'set-next-selection-coding-system))
+;; XEmacs change: make code readable, and sanity-check EOL-TYPE.
(defun coding-system-change-eol-conversion (coding-system eol-type)
- "Return a coding system which differs from CODING-SYSTEM in eol conversion.
-The returned coding system converts end-of-line by EOL-TYPE
-but text as the same way as CODING-SYSTEM.
-EOL-TYPE should be `lf', `crlf', `cr' or nil.
-If EOL-TYPE is nil, the returned coding system detects
-how end-of-line is formatted automatically while decoding.
-
-EOL-TYPE can be specified by an symbol `unix', `dos' or `mac'.
-They means `lf', `crlf', and `cr' respectively."
- (if (symbolp eol-type)
- (setq eol-type (cond ((or (eq eol-type 'unix)
- (eq eol-type 'lf))
- 'eol-lf)
- ((or (eq eol-type 'dos)
- (eq eol-type 'crlf))
- 'eol-crlf)
- ((or (eq eol-type 'mac)
- (eq eol-type 'cr))
- 'eol-cr)
- (t eol-type))))
+ "Return a version of CODING-SYSTEM that provides EOL-TYPE eol conversion.
+EOL-TYPE should be `lf', `crlf', `cr' or nil. nil means the returned coding
+system automatically detects the end-of-line convention while decoding.
+EOL-TYPE may also be one of the symbols `unix', `dos' or `mac', meaning
+`lf', `crlf', and `cr' respectively."
+ (setq eol-type (cond ((or (eq eol-type 'unix) (eq eol-type 'lf)) 'eol-lf)
+ ((or (eq eol-type 'dos) (eq eol-type 'crlf)) 'eol-crlf)
+ ((or (eq eol-type 'mac) (eq eol-type 'cr)) 'eol-cr)
+ ((null eol-type) nil)
+ (t (error 'invalid-constant eol-type))))
(coding-system-name
- (let ((orig-eol-type (coding-system-eol-type coding-system)))
- (if (null orig-eol-type)
- (if (not eol-type)
- coding-system
- (coding-system-property coding-system eol-type))
- (let ((base (coding-system-base coding-system)))
- (if (not eol-type)
- base
- (if (eq eol-type orig-eol-type)
- coding-system
- (setq orig-eol-type (coding-system-eol-type base))
- (if (null orig-eol-type)
- (coding-system-property base eol-type)))))))))
+ (let ((orig-eol-type (cdr (assq (coding-system-eol-type coding-system)
+ '((lf . eol-lf)
+ (cr . eol-cr)
+ (crlf . eol-crlf)
+ ;; #### also returns nil if not a key
+ (nil . nil)))))
+ (base (coding-system-base coding-system)))
+ (cond ((eq eol-type orig-eol-type) coding-system)
+ ((null orig-eol-type)
+ (coding-system-property coding-system eol-type))
+ ((null eol-type) base)
+ ((null (coding-system-eol-type base))
+ (coding-system-property base eol-type))
+ (t (warn "couldn't change EOL conversion of %s from %s to %s."
+ coding-system orig-eol-type eol-type)
+ ;; return nil for compatibility with old code
+ nil)))))
;; (defun coding-system-change-text-conversion (coding-system coding)
;; "Return a coding system which differs from CODING-SYSTEM in text conversion.
--
School of Systems and Information Engineering
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Ask not how you can "do" free software business;
ask what your business can "do for" free software.