[uim-commit] r2254 - in branches/r5rs/sigscheme: . test

yamaken at freedesktop.org yamaken at freedesktop.org
Fri Nov 25 01:30:59 PST 2005


Author: yamaken
Date: 2005-11-25 01:30:53 -0800 (Fri, 25 Nov 2005)
New Revision: 2254

Modified:
   branches/r5rs/sigscheme/encoding.c
   branches/r5rs/sigscheme/test/test-enc-sjis.scm
Log:
* sigscheme/encoding.c
  - (sjis_int2str): Fix mishandling for single byte char
* sigscheme/test/test-enc-sjis.scm
  - Add some tests


Modified: branches/r5rs/sigscheme/encoding.c
===================================================================
--- branches/r5rs/sigscheme/encoding.c	2005-11-25 08:33:54 UTC (rev 2253)
+++ branches/r5rs/sigscheme/encoding.c	2005-11-25 09:30:53 UTC (rev 2254)
@@ -789,23 +789,23 @@
 
 static uchar *sjis_int2str(uchar *dst, int ch)
 {
-    uchar seq[2];
+    uchar high, low;
 
 #if SCM_STRICT_ENCODING_CHECK
     if (ch >> CHAR_BITS * 2)
         return NULL;
 #endif
-    seq[0] = ch >> CHAR_BITS;
-    seq[1] = ch & BYTE_MASK;
+    high = ch >> CHAR_BITS;
+    low  = ch & BYTE_MASK;
 
-    *dst++ = seq[0];
-    if (IS_LEAD(seq[0])) {
+    if (IS_LEAD(high)) {
 #if SCM_STRICT_ENCODING_CHECK
-        if (!IS_TRAIL(seq[1]))
+        if (!IS_TRAIL(high))
             return NULL;
 #endif
-        *dst++ = seq[1];
+        *dst++ = high;
     }
+    *dst++ = low;
     *dst = '\0';
 
     return dst;

Modified: branches/r5rs/sigscheme/test/test-enc-sjis.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-enc-sjis.scm	2005-11-25 08:33:54 UTC (rev 2253)
+++ branches/r5rs/sigscheme/test/test-enc-sjis.scm	2005-11-25 09:30:53 UTC (rev 2254)
@@ -36,6 +36,8 @@
 
 (load "./test/unittest.scm")
 
+(set! *test-track-progress* #t)
+
 (assert-equal? "string 1" "”ül‚É‚Í" (string #\”ü #\l #\‚É #\‚Í))
 (assert-equal? "list->string 1" "3“ú‚Å" (list->string '(#\3 #\“ú #\‚Å)))
 (assert-equal? "string->list 1" '(#\‚Ÿ #\‚« #\‚é) (string->list "‚Ÿ‚«‚é"))
@@ -58,4 +60,21 @@
 (assert-equal? "string 2" str1 (apply string str1-list))
 (assert-equal? "list->string 2" str1-list (string->list str1))
 
+;; JIS X 0201 kana (single byte)
+(assert-equal? "JIS X 0201 kana" #\Ë (integer->char #xcb))
+(assert-equal? "JIS X 0201 kana" #xcb (char->integer #\Ë))
+(assert-equal? "JIS X 0201 kana" '(#\Ë) (string->list "Ë"))
+(assert-equal? "JIS X 0201 kana" "Ë" (list->string '(#\Ë)))
+
+(assert-equal? "JIS X 0208 kana #1" #\ƒ„ (integer->char #x8384))
+(assert-equal? "JIS X 0208 kana #2" (car (string->list "ƒ„")) (integer->char #x8384))
+(assert-equal? "JIS X 0208 kana #3" #x8384 (char->integer #\ƒ„))
+(assert-equal? "JIS X 0208 kana #4" #x8384 (char->integer (integer->char #x8384)))
+(assert-equal? "JIS X 0208 kana #5" '(#\ƒ„) (string->list "ƒ„"))
+(assert-equal? "JIS X 0208 kana #6" "ƒ„" (list->string '(#\ƒ„)))
+(assert-equal? "JIS X 0208 kana #7" "ƒ„" (list->string (string->list "ƒ„")))
+
+(assert-equal? "JIS X 0201 kana and 0208 kana" '(#\Ë #\ƒƒ) (string->list "˃ƒ"))
+(assert-equal? "JIS X 0201 kana and 0208 kana" "˃ƒ" (list->string '(#\Ë #\ƒƒ)))
+
 (total-report)



More information about the uim-commit mailing list