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

yamaken at freedesktop.org yamaken at freedesktop.org
Sun Jan 8 01:29:51 PST 2006


Author: yamaken
Date: 2006-01-08 01:29:48 -0800 (Sun, 08 Jan 2006)
New Revision: 2841

Modified:
   branches/r5rs/sigscheme/encoding.c
   branches/r5rs/sigscheme/operations.c
Log:
* sigscheme/encoding.c
  - (scm_mb_bare_c_strlen): Simplify with SCM_MBS_INIT2()
* sigscheme/operations.c
  - (scm_p_string_ref, scm_p_string_setd, scm_p_substring): Ditto
  - (scm_p_string2list):
    * Ditto
    * Simplify with SCM_CHARCODEC_READ_CHAR()


Modified: branches/r5rs/sigscheme/encoding.c
===================================================================
--- branches/r5rs/sigscheme/encoding.c	2006-01-08 09:23:44 UTC (rev 2840)
+++ branches/r5rs/sigscheme/encoding.c	2006-01-08 09:29:48 UTC (rev 2841)
@@ -290,9 +290,7 @@
 {
     ScmMultibyteString mbs;
 
-    SCM_MBS_INIT(mbs);
-    SCM_MBS_SET_STR(mbs, s);
-    SCM_MBS_SET_SIZE(mbs, strlen(s));
+    SCM_MBS_INIT2(mbs, s, strlen(s));
     return scm_mb_strlen(mbs);
 }
 

Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c	2006-01-08 09:23:44 UTC (rev 2840)
+++ branches/r5rs/sigscheme/operations.c	2006-01-08 09:29:48 UTC (rev 2841)
@@ -1316,9 +1316,7 @@
     if (idx < 0 || SCM_STRING_LEN(str) <= idx)
         ERR_OBJ("index out of range", k);
 
-    SCM_MBS_INIT(mbs);
-    SCM_MBS_SET_STR(mbs, SCM_STRING_STR(str));
-    SCM_MBS_SET_SIZE(mbs, strlen(SCM_STRING_STR(str)));
+    SCM_MBS_INIT2(mbs, SCM_STRING_STR(str), strlen(SCM_STRING_STR(str)));
     mbs = scm_mb_strref(mbs, idx);
 
     ch = SCM_CHARCODEC_STR2INT(scm_current_char_codec, SCM_MBS_GET_STR(mbs),
@@ -1352,9 +1350,7 @@
         ERR_OBJ("index out of range", k);
 
     /* point at the char that to be replaced */
-    SCM_MBS_INIT(mbs_ch);
-    SCM_MBS_SET_STR(mbs_ch, c_str);
-    SCM_MBS_SET_SIZE(mbs_ch, strlen(c_str));
+    SCM_MBS_INIT2(mbs_ch, c_str, strlen(c_str));
     mbs_ch = scm_mb_strref(mbs_ch, idx);
     orig_ch_len = SCM_MBS_GET_SIZE(mbs_ch);
     prefix_len = SCM_MBS_GET_STR(mbs_ch) - c_str;
@@ -1434,9 +1430,7 @@
 
     /* substring */
     c_str = SCM_STRING_STR(str);
-    SCM_MBS_INIT(mbs);
-    SCM_MBS_SET_STR(mbs, c_str);
-    SCM_MBS_SET_SIZE(mbs, strlen(c_str));
+    SCM_MBS_INIT2(mbs, c_str, strlen(c_str));
     mbs = scm_mb_substring(mbs, c_start, c_end - c_start);
 
     /* copy the substring */
@@ -1491,32 +1485,17 @@
     ScmObj res;
     int ch;
     ScmMultibyteString mbs;
-    ScmMultibyteCharInfo mbc;
-    ScmMultibyteState state;
     DECLARE_FUNCTION("string->list", procedure_fixed_1);
 
     ENSURE_STRING(str);
 
-    SCM_MBS_INIT(mbs);
-    SCM_MBS_SET_STR(mbs, SCM_STRING_STR(str));
-    SCM_MBS_SET_SIZE(mbs, strlen(SCM_STRING_STR(str)));
+    SCM_MBS_INIT2(mbs, SCM_STRING_STR(str), strlen(SCM_STRING_STR(str)));
 
     res = SCM_NULL;
     SCM_QUEUE_POINT_TO(q, res);
     while (SCM_MBS_GET_SIZE(mbs)) {
-        state = SCM_MBS_GET_STATE(mbs);
-        mbc = SCM_CHARCODEC_SCAN_CHAR(scm_current_char_codec, mbs);
-        if (SCM_MBCINFO_ERRORP(mbc) || SCM_MBCINFO_INCOMPLETEP(mbc))
-            ERR("string->list: invalid char sequence");
-        ch = SCM_CHARCODEC_STR2INT(scm_current_char_codec,
-                                   SCM_MBS_GET_STR(mbs),
-                                   SCM_MBCINFO_GET_SIZE(mbc),
-                                   state);
-        if (ch == EOF)
-            ERR("string->list: invalid char sequence");
-
+        ch = SCM_CHARCODEC_READ_CHAR(scm_current_char_codec, mbs);
         SCM_QUEUE_ADD(q, MAKE_CHAR(ch));
-        SCM_MBS_SKIP_CHAR(mbs, mbc);
     }
 
     return res;



More information about the uim-commit mailing list