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

kzk at freedesktop.org kzk at freedesktop.org
Wed Nov 9 10:35:19 PST 2005


Author: kzk
Date: 2005-11-09 10:35:15 -0800 (Wed, 09 Nov 2005)
New Revision: 2112

Modified:
   branches/r5rs/sigscheme/read.c
Log:
* sigscheme/read.c
  - (read_char): support #\xFF style character. now only support ASCII.


Modified: branches/r5rs/sigscheme/read.c
===================================================================
--- branches/r5rs/sigscheme/read.c	2005-11-09 15:51:27 UTC (rev 2111)
+++ branches/r5rs/sigscheme/read.c	2005-11-09 18:35:15 UTC (rev 2112)
@@ -332,16 +332,27 @@
 {
     char *ch = read_char_sequence(port);
     const ScmSpecialCharInfo *info = Scm_special_char_table;
+    char *first_nondigit = NULL;
 
     CDBG((SCM_DBG_PARSER, "read_char : ch = %s", ch));
 
-    /* check special sequence */
-    for (; info->esc_seq; info++) {
-        if (strcmp(ch, info->lex_rep) == 0) {
-            ch[0] = info->code;
-            ch[1] = '\0';
-            break;
+    /* check #\x0F style character (defined in R6RS) */
+    if (ch && ch[0] == 'x' && strlen(ch) > 1) {
+        /* FIXME: only supports ASCII */
+        ch[0] = (char)strtol(ch + 1, &first_nondigit, 16);
+        if (*first_nondigit) {
+            SigScm_Error("invalid character form\n");
         }
+        ch[1] = '\0';
+    } else {
+        /* check special sequence */
+        for (; info->esc_seq; info++) {
+            if (strcmp(ch, info->lex_rep) == 0) {
+                ch[0] = info->code;
+                ch[1] = '\0';
+                break;
+            }
+        }
     }
 
     return Scm_NewChar(ch);



More information about the uim-commit mailing list