1. xemacs
  2. mule-base

Commits

aidan  committed ba6d997

Make fsf-compat-unicode.el work with recent revisions to 21.5

  • Participants
  • Parent commits f2b70f2
  • Branches default

Comments (0)

Files changed (2)

File ChangeLog

View file
+2007-07-27  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* fsf-compat-unicode.el:
+	* fsf-compat-unicode.el (fsf-compat-ccl-program): New.
+	* fsf-compat-unicode.el (fsf-compat-init-mule-unicode-charsets):
+	Use fsf-compat-ccl-program, which better reflects the CCL
+	behaviour in force at the time it was compiled. Also move the CCL
+	program constant to actually shifting eight bits at a time.
+
 2007-07-24  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.51 released.

File fsf-compat-unicode.el

View file
 ;;; Code:
 
 ;;; Only for 21.5 and newer. 
-(unless (and (fboundp 'encode-char)
-             (eq #x31C (with-fboundp '(encode-char decode-char)
-                     (encode-char (decode-char 'ucs #x31C) 'ucs))))
-  (error "Unicode support needed for this file not available!"))
 
+(eval-when-compile (require 'ccl))
 
-(if (eval-when-compile
-      (and (> emacs-major-version 20)  
-	   (> emacs-minor-version 4)
-	   (featurep 'mule)))
+;; Check at runtime that the Unicode support is available, and that its
+;; coverage is good enough.
+(unless (if-fboundp 'encode-char
+	    (with-fboundp '(encode-char decode-char)
+	      (eq #x31C (encode-char (decode-char 'ucs #x31C) 'ucs))))
+  (error 'text-conversion-error
+	 "Unicode support needed is not available in your XEmacs."))
 
-    ;; If we're being compiled by 21.5, use the actual define-ccl-program
-    ;; macro, but evaluated at runtime. 
-    ;;
-    ;; Having this as 
-    ;;
-    ;;   (eval-when-compile (and (featurep 'mule) (macroexpand
-    ;;   '(define-ccl-program ...))
-    ;;
-    ;; in order to have the macro evaluated at compile time, results
-    ;; in the statement being empty in the compiled file, which as I
-    ;; understand it is a bug.
-
-    (eval
-     '(define-ccl-program fsf-compat-ccl-encode-to-ucs-2 
-       `(1 
-	 ((r1 = (r1 << 7)) 
-	  (r1 = (r1 | r2)) 
-	  (mule-to-unicode r0 r1) 
-	  (r1 = (r0 >> 7)) 
-	  (r2 = (r0 & 255)))) 
-       "CCL program to transform Mule characters to UCS-2."))
-
-  ;; Pre-expand the macro for 21.4. 21.4 will error on loading this file, but 
-  ;; it may compile it. define-ccl-program should not be a macro, but that's 
-  ;; by the way. 
-  (let ((prog [1 10 131127 8 98872 65823 147513 8 82009 255 22])) 
-    (defconst fsf-compat-ccl-encode-to-ucs-2 prog 
-      "CCL program to transform Mule characters to UCS-2.") 
-    (put (quote fsf-compat-ccl-encode-to-ucs-2) 
-	 (quote ccl-program-idx) 
-	 (register-ccl-program (quote fsf-compat-ccl-encode-to-ucs-2) prog))  
-    nil))
+;; For redisplay of these character sets, provide a CCL program to address
+;; iso10646-1 X11 fonts.
+(defvar fsf-compat-ccl-program 
+  (eval-when-compile
+    (let ((pre-existing [1 10 131127 7 98872 65823 147513 7 82009 127 22]))
+      (when (and (> emacs-major-version 20) (> emacs-minor-version 4)
+                 (featurep 'mule))
+        ;; In the event that we're compiling on 21.5, check that the
+        ;; pre-existing constant reflects the intended CCL
+        ;; program. Otherwise, just go ahead and use it.
+        (assert (equal pre-existing
+                       (ccl-compile
+                        `(1 
+                          ((r1 = (r1 << 7)) 
+                           (r1 = (r1 | r2)) 
+                           (mule-to-unicode r0 r1) 
+                           (r1 = (r0 >> 7)) 
+                           (r2 = (r0 & #x7F))))))
+                nil 
+                "The pre-compiled CCL program appears broken. "))
+      pre-existing))
+  "CCL program required by `fsf-compat-init-mule-unicode-charsets'.")
 
 (defun fsf-compat-init-mule-unicode-charsets ()
   "Make some Mule character sets that the FSF uses available in XEmacs.
 		    (format 
 		     "Unicode subset (U+%04X..U+%04X) for FSF compatibility."
 		     first-ucs last-ucs)
-		    (list 'dimension 2 
-			  'registries ["iso10646-1"]
-			  'chars 96
-			  'columns 1
-			  'direction 'l2r
-			  'final final
-			  'graphic 0
-			  'short-name (format "Unicode subset %c" final)
-			  'long-name (format "Unicode subset (U+%04X..U+%04X)"
-					     first-ucs last-ucs)
-			  'ccl-program 'fsf-compat-ccl-encode-to-ucs-2))
+		    `(dimension 2 
+                      registries ["iso10646-1"]
+                      chars 96
+                      columns 1
+                      direction l2r
+                      final final
+                      graphic 0
+                      short-name ,(format "Unicode subset %c" final)
+                      long-name ,(format "Unicode subset (U+%04X..U+%04X)"
+                                         first-ucs last-ucs)
+                      ccl-program ,fsf-compat-ccl-program))
       ;; The names of the character sets lie, at least as of GNU Emacs
       ;; 22.0.50.3. The difference appears to be that they keep assigning
       ;; code points until the end of the 96x96 space of the character sets.