changeset 3690:d6a215ad08b8

[xemacs-hg @ 2006-11-20 19:21:47 by aidan] Eliminate a couple of CCL bugs with control-1 characters.
author aidan
date Mon, 20 Nov 2006 19:21:56 +0000
parents 844f6af613f6
children 94cc244db105
files src/ChangeLog src/mule-ccl.c tests/ChangeLog tests/automated/mule-tests.el
diffstat 4 files changed, 63 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Nov 19 22:51:04 2006 +0000
+++ b/src/ChangeLog	Mon Nov 20 19:21:56 2006 +0000
@@ -1,3 +1,12 @@
+2006-11-20  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* mule-ccl.c (CCL_MAKE_CHAR):
+	* mule-ccl.c (ccl_driver):
+	Eliminate a CCL bug with control-1 chars and
+	write-multibyte-character--thank you for the report, Ilya--and
+	eliminate a crash when a non-existent charset ID is specified for
+	a mule-to-unicode call.
+
 2006-11-18  Mike Sperber  <mike@xemacs.org>
 
 	* window.c (window_pixel_height_to_char_height): Cater to the
--- a/src/mule-ccl.c	Sun Nov 19 22:51:04 2006 +0000
+++ b/src/mule-ccl.c	Mon Nov 20 19:21:56 2006 +0000
@@ -850,13 +850,17 @@
    macro is only used in the MuleToUnicode transformation.  */
 #define CCL_MAKE_CHAR(charset, code, c)				\
   do {								\
+                                                                \
+    if (!POSSIBLE_LEADING_BYTE_P(charset))                      \
+      CCL_INVALID_CMD;                                          \
+                                                                \
     if ((charset) == LEADING_BYTE_ASCII)			\
       {								\
 	c = (code) & 0xFF;					\
       }								\
     else if ((charset) == LEADING_BYTE_CONTROL_1)		\
       {								\
-	c = ((code) & 0xFF) - 0xA0;				\
+	c = ((code) & 0x1F) + 0x80;				\
       }								\
     else if (!NILP(charset_by_leading_byte(charset))		\
 	     && ((code) >= 32)					\
@@ -1390,7 +1394,7 @@
 	      if (i == LEADING_BYTE_ASCII) 
 		i = reg[rrr] & 0xFF;
 	      else if (LEADING_BYTE_CONTROL_1 == i)
-		i = ((reg[rrr] & 0xFF) - 0xA0);
+		i = ((reg[rrr] & 0x1F) + 0x80);
 	      else if (POSSIBLE_LEADING_BYTE_P(i) &&
 		       !NILP(charset_by_leading_byte(i)))
 		{
--- a/tests/ChangeLog	Sun Nov 19 22:51:04 2006 +0000
+++ b/tests/ChangeLog	Mon Nov 20 19:21:56 2006 +0000
@@ -1,3 +1,9 @@
+2006-11-20  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* automated/mule-tests.el (featurep):
+	Add tests to make sure the fixes to the CCL bugs I just checked in
+	don't regress.
+
 2006-08-05  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* automated/lisp-reader-tests.el:
--- a/tests/automated/mule-tests.el	Sun Nov 19 22:51:04 2006 +0000
+++ b/tests/automated/mule-tests.el	Mon Nov 20 19:21:56 2006 +0000
@@ -400,6 +400,48 @@
 		       (encode-coding-string xemacs-character 'ctext))))))
 
   ;;---------------------------------------------------------------
+  ;; Regression test for a couple of CCL-related bugs. 
+  ;;---------------------------------------------------------------
+
+  (let ((ccl-vector [0 0 0 0 0 0 0 0 0]))
+    (define-ccl-program ccl-write-two-control-1-chars 
+      `(1 
+	((r0 = ,(charset-id 'control-1))
+	 (r1 = 0) 
+	 (write-multibyte-character r0 r1) 
+	 (r1 = 31) 
+	 (write-multibyte-character r0 r1))) 
+      "CCL program that writes two control-1 multibyte characters.") 
+ 
+    (Assert (equal 
+	     (ccl-execute-on-string 'ccl-write-two-control-1-chars  
+				    ccl-vector "") 
+	     (format "%c%c" (make-char 'control-1 0) 
+		     (make-char 'control-1 31))))
+
+    (define-ccl-program ccl-unicode-two-control-1-chars 
+      `(1 
+	((r0 = ,(charset-id 'control-1))
+	 (r1 = 31) 
+	 (mule-to-unicode r0 r1) 
+	 (r4 = r0) 
+	 (r3 = ,(charset-id 'control-1))
+	 (r2 = 0) 
+	 (mule-to-unicode r3 r2))) 
+      "CCL program that writes two control-1 UCS code points in r3 and r4")
+
+    ;; Re-initialise the vector, mainly to clear the instruction counter,
+    ;; which is its last element.
+    (setq ccl-vector [0 0 0 0 0 0 0 0 0])
+ 
+    (ccl-execute-on-string 'ccl-unicode-two-control-1-chars ccl-vector "") 
+ 
+    (Assert (and (eq (aref ccl-vector 3)  
+                   (encode-char (make-char 'control-1 0) 'ucs)) 
+               (eq (aref ccl-vector 4)  
+                   (encode-char (make-char 'control-1 31) 'ucs)))))
+
+  ;;---------------------------------------------------------------
   ;; Test charset-in-* functions
   ;;---------------------------------------------------------------
   (with-temp-buffer