[uim-commit] r2207 - branches/r5rs/sigscheme

kzk at freedesktop.org kzk at freedesktop.org
Mon Nov 21 11:06:00 PST 2005


Author: kzk
Date: 2005-11-21 11:05:55 -0800 (Mon, 21 Nov 2005)
New Revision: 2207

Modified:
   branches/r5rs/sigscheme/debug.c
Log:
* now, all tests in test-char.scm is passed.

* sigscheme/debug.c
  - (print_char): handling printable char and hexadecimal char


Modified: branches/r5rs/sigscheme/debug.c
===================================================================
--- branches/r5rs/sigscheme/debug.c	2005-11-21 19:00:52 UTC (rev 2206)
+++ branches/r5rs/sigscheme/debug.c	2005-11-21 19:05:55 UTC (rev 2207)
@@ -309,7 +309,7 @@
 static void print_char(ScmObj port, ScmObj obj, enum OutputType otype)
 {
     const ScmSpecialCharInfo *info = NULL;
-    const char *lex_rep = NULL;
+    char *lex_rep = NULL;
 
     /* sanity check */
     if (SCM_CHAR_VALUE(obj) == NULL)
@@ -318,12 +318,28 @@
     switch (otype) {
     case AS_WRITE:
         lex_rep = SCM_CHAR_VALUE(obj);
-        for (info = Scm_special_char_table; info->esc_seq; info++) {
-            if (SCM_CHAR_VALUE(obj)[0] == info->code) {
-                lex_rep = info->lex_rep;
-                break;
+        /* single byte */
+        if (strlen(lex_rep) < 2) {
+            /* search in the Scm_special_char_table */
+            for (info = Scm_special_char_table; info->esc_seq; info++) {
+                if (SCM_CHAR_VALUE(obj)[0] == info->code) {
+                    SigScm_PortPrintf(port, "#\\%s", info->lex_rep);
+                    return;
+                }
             }
+            /* not found in the table*/
+            if (isprint(SCM_CHAR_VALUE(obj)[0])) {
+                SigScm_PortPrintf(port, "#\\%s", SCM_CHAR_VALUE(obj));
+            } else {
+                /* convert to hexadecimal format */ 
+                lex_rep = (char*)malloc(sizeof(char) * 4);
+                snprintf(lex_rep, 4, "x%02x", (int)SCM_CHAR_VALUE(obj)[0]);
+                SigScm_PortPrintf(port, "#\\%s", lex_rep);
+                free(lex_rep);
+            }
+            return;
         }
+        /* multi byte */
         SigScm_PortPrintf(port, "#\\%s", lex_rep);
         break;
 



More information about the uim-commit mailing list