[uim-commit] r3055 - branches/r5rs/sigscheme/src

yamaken at freedesktop.org yamaken at freedesktop.org
Tue Jan 31 17:49:38 PST 2006


Author: yamaken
Date: 2006-01-31 17:49:34 -0800 (Tue, 31 Jan 2006)
New Revision: 3055

Modified:
   branches/r5rs/sigscheme/src/load.c
   branches/r5rs/sigscheme/src/sigscheme.c
   branches/r5rs/sigscheme/src/sigschemeinternal.h
   branches/r5rs/sigscheme/src/storage.c
   branches/r5rs/sigscheme/src/string.c
   branches/r5rs/sigscheme/src/write.c
Log:
* sigscheme/src/sigschemeinternal.h
  - (ENSURE_STATEFUL_CODEC, ENSURE_STATELESS_CODEC): Disable when
    !SCM_USE_MULTIBYTE_CHAR
* sigscheme/src/string.c
  - (scm_p_make_string, scm_p_string_setd, scm_p_list2string,
    scm_p_string_filld): Remove multibyte char handlings when
    !SCM_USE_MULTIBYTE_CHAR
* sigscheme/src/load.c
  - (scm_load_internal): Ditto
* sigscheme/src/storage.c
  - (scm_make_string_internal): Ditto
* sigscheme/src/sigscheme.c
  - (scm_interpret_argv): Ditto
* sigscheme/src/write.c
  - (write_string): Ditto


Modified: branches/r5rs/sigscheme/src/load.c
===================================================================
--- branches/r5rs/sigscheme/src/load.c	2006-02-01 00:58:20 UTC (rev 3054)
+++ branches/r5rs/sigscheme/src/load.c	2006-02-01 01:49:34 UTC (rev 3055)
@@ -112,7 +112,9 @@
 {
     ScmObj path, port, sexp;
     char *c_path;
+#if SCM_USE_MULTIBYTE_CHAR
     ScmCharCodec *saved_codec;
+#endif
     DECLARE_INTERNAL_FUNCTION("load");
 
     CDBG((SCM_DBG_FILE, "loading %s", filename));
@@ -124,7 +126,9 @@
     path = MAKE_IMMUTABLE_STRING(c_path, STRLEN_UNKNOWN);
     port = scm_p_open_input_file(path);
 
+#if SCM_USE_MULTIBYTE_CHAR
     saved_codec = scm_current_char_codec;
+#endif
 #if SCM_USE_SRFI22
     if (scm_port_peek_char(port) == '#')
         interpret_script_prelude(port);
@@ -135,7 +139,9 @@
         EVAL(sexp, SCM_INTERACTION_ENV);
 
     scm_p_close_input_port(port);
+#if SCM_USE_MULTIBYTE_CHAR
     scm_current_char_codec = saved_codec;
+#endif
 
     CDBG((SCM_DBG_FILE, "done."));
 }

Modified: branches/r5rs/sigscheme/src/sigscheme.c
===================================================================
--- branches/r5rs/sigscheme/src/sigscheme.c	2006-02-01 00:58:20 UTC (rev 3054)
+++ branches/r5rs/sigscheme/src/sigscheme.c	2006-02-01 01:49:34 UTC (rev 3055)
@@ -262,6 +262,7 @@
     rest = argp;
 
     if (encoding) {
+#if SCM_USE_MULTIBYTE_CHAR
         specified_codec = scm_mb_find_codec(encoding);
         if (!specified_codec) {
             if (scm_initialized) {
@@ -275,6 +276,9 @@
             }
         }
         scm_current_char_codec = specified_codec;
+#else
+        fprintf(stderr, SCM_ERR_HEADER "encoding switching is not supported on this build\n");
+#endif
     }
 
     return rest;

Modified: branches/r5rs/sigscheme/src/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/src/sigschemeinternal.h	2006-02-01 00:58:20 UTC (rev 3054)
+++ branches/r5rs/sigscheme/src/sigschemeinternal.h	2006-02-01 01:49:34 UTC (rev 3055)
@@ -373,6 +373,7 @@
     (SCM_VECTOR_MUTABLEP(vec)                                                \
      || (ERR_OBJ("attempted to modify immutable vector", vec), 1))
 
+#if SCM_USE_MULTIBYTE_CHAR
 #define ENSURE_STATEFUL_CODEC(codec)                                         \
     (SCM_CHARCODEC_STATEFULP(codec)                                          \
      || (ERR("stateful character codec required but got: %s",                \
@@ -381,6 +382,7 @@
     (!SCM_CHARCODEC_STATEFULP(codec)                                         \
      || (ERR("stateless character codec required but got: %s",               \
              SCM_CHARCODEC_ENCODING(codec)), 0))
+#endif /* SCM_USE_MULTIBYTE_CHAR */
 
 #define ENSURE_ALLOCATED SCM_ENSURE_ALLOCATED
 

Modified: branches/r5rs/sigscheme/src/storage.c
===================================================================
--- branches/r5rs/sigscheme/src/storage.c	2006-02-01 00:58:20 UTC (rev 3054)
+++ branches/r5rs/sigscheme/src/storage.c	2006-02-01 01:49:34 UTC (rev 3055)
@@ -232,8 +232,13 @@
 
     SCM_ASSERT(str);
 
-    if (len == STRLEN_UNKNOWN)
+    if (len == STRLEN_UNKNOWN) {
+#if SCM_USE_MULTIBYTE_CHAR
         len = scm_mb_bare_c_strlen(scm_current_char_codec, str);
+#else
+        len = strlen(str);
+#endif
+    }
 
     obj = scm_alloc_cell();
     SCM_ENTYPE_STRING(obj);

Modified: branches/r5rs/sigscheme/src/string.c
===================================================================
--- branches/r5rs/sigscheme/src/string.c	2006-02-01 00:58:20 UTC (rev 3054)
+++ branches/r5rs/sigscheme/src/string.c	2006-02-01 01:49:34 UTC (rev 3055)
@@ -372,7 +372,9 @@
 #endif
     DECLARE_FUNCTION("make-string", procedure_variadic_1);
 
+#if SCM_USE_MULTIBYTE_CHAR
     ENSURE_STATELESS_CODEC(scm_current_char_codec);
+#endif
     ENSURE_INT(length);
     len = SCM_INT_VALUE(length);
     if (len == 0)
@@ -492,7 +494,9 @@
 #endif
     DECLARE_FUNCTION("string-set!", procedure_fixed_3);
 
+#if SCM_USE_MULTIBYTE_CHAR
     ENSURE_STATELESS_CODEC(scm_current_char_codec);
+#endif
     ENSURE_STRING(str);
     ENSURE_MUTABLE_STRING(str);
     ENSURE_INT(k);
@@ -875,7 +879,9 @@
 #endif
     DECLARE_FUNCTION("list->string", procedure_fixed_1);
 
+#if SCM_USE_MULTIBYTE_CHAR
     ENSURE_STATELESS_CODEC(scm_current_char_codec);
+#endif
     ENSURE_LIST(lst);
 
     if (NULLP(lst))
@@ -947,7 +953,9 @@
 #endif
     DECLARE_FUNCTION("string-fill!", procedure_fixed_2);
 
+#if SCM_USE_MULTIBYTE_CHAR
     ENSURE_STATELESS_CODEC(scm_current_char_codec);
+#endif
     ENSURE_STRING(str);
     ENSURE_MUTABLE_STRING(str);
     ENSURE_CHAR(ch);

Modified: branches/r5rs/sigscheme/src/write.c
===================================================================
--- branches/r5rs/sigscheme/src/write.c	2006-02-01 00:58:20 UTC (rev 3054)
+++ branches/r5rs/sigscheme/src/write.c	2006-02-01 01:49:34 UTC (rev 3055)
@@ -278,20 +278,24 @@
 static void
 write_string(ScmObj port, ScmObj obj, enum OutputType otype)
 {
+#if SCM_USE_MULTIBYTE_CHAR
     ScmCharCodec *codec;
     ScmMultibyteString mbs;
+    size_t len;
+#else
+    scm_int_t i, len;
+#endif
     const ScmSpecialCharInfo *info;
     const char *str;
-    size_t len;
     scm_ichar_t c;
     DECLARE_INTERNAL_FUNCTION("write");
 
     str = SCM_STRING_STR(obj);
-    len = strlen(str);
 
     switch (otype) {
     case AS_WRITE:
         scm_port_put_char(port, '\"'); /* opening doublequote */
+#if SCM_USE_MULTIBYTE_CHAR
         if (scm_current_char_codec != scm_port_codec(port)) {
             /* Since the str does not have its encoding information, here
              * assumes that scm_current_char_codec is that. And then SigScheme
@@ -299,10 +303,16 @@
              * as-is. */
             scm_port_puts(port, str);
         } else {
+            len = strlen(str);
             codec = scm_port_codec(port);
             SCM_MBS_INIT2(mbs, str, len);
             while (SCM_MBS_GET_SIZE(mbs)) {
                 c = SCM_CHARCODEC_READ_CHAR(codec, mbs);
+#else /* SCM_USE_MULTIBYTE_CHAR */
+            len = SCM_STRING_LEN(obj);
+            for (i = 0; i < len; i++) {
+                c = str[i];
+#endif /* SCM_USE_MULTIBYTE_CHAR */
                 for (info = scm_special_char_table; info->esc_seq; info++) {
                     if (c == info->code) {
                         scm_port_puts(port, info->esc_seq);



More information about the uim-commit mailing list