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

yamaken at freedesktop.org yamaken at freedesktop.org
Mon Jan 9 08:40:05 PST 2006


Author: yamaken
Date: 2006-01-09 08:40:00 -0800 (Mon, 09 Jan 2006)
New Revision: 2870

Modified:
   branches/r5rs/sigscheme/error.c
   branches/r5rs/sigscheme/operations.c
   branches/r5rs/sigscheme/storage-symbol.c
Log:
* sigscheme/error.c
  - (scm_show_backtrace): Simplify with FOR_EACH
* sigscheme/operations.c
  - (ASSOC_BODY):
    * Simplify with FOR_EACH()
    * Remove args for tmp variable
  - (scm_p_assq, scm_p_assv, scm_p_assoc): Follow the change of
    ASSOC_BODY()
  - (scm_p_list2string): Simplify with FOR_EACH()
* sigscheme/storage-symbol.c
  - (scm_intern, scm_symbol_bound_to): Simplify with FOR_EACH()


Modified: branches/r5rs/sigscheme/error.c
===================================================================
--- branches/r5rs/sigscheme/error.c	2006-01-09 16:03:46 UTC (rev 2869)
+++ branches/r5rs/sigscheme/error.c	2006-01-09 16:40:00 UTC (rev 2870)
@@ -365,17 +365,17 @@
 scm_show_backtrace(ScmObj trace_stack)
 {
 #if SCM_DEBUG
-    ScmObj top, frame, env, obj;
+    ScmObj frame, env, obj, elm;
+    DECLARE_INTERNAL_FUNCTION("scm_show_backtrace");
 
     scm_port_printf(scm_err, SCM_BACKTRACE_HEADER);
 
     /* show each frame's obj */
-    for (top = trace_stack; !NULLP(top); top = CDR(top)) {
+    FOR_EACH (frame, trace_stack) {
 #if SCM_DEBUG_BACKTRACE_SEP
         scm_port_printf(scm_err, SCM_BACKTRACE_SEP);
 #endif
 
-        frame = CAR(top);
         env = TRACE_FRAME_ENV(frame);
         obj = TRACE_FRAME_OBJ(frame);
 
@@ -389,8 +389,8 @@
             break;
 
         case ScmCons:
-            for (; CONSP(obj); obj = CDR(obj))
-                show_arg(CAR(obj), env);
+            FOR_EACH (elm, obj)
+                show_arg(elm, env);
             /* dot list */
             if (SYMBOLP(obj))
                 show_arg(obj, env);

Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c	2006-01-09 16:03:46 UTC (rev 2869)
+++ branches/r5rs/sigscheme/operations.c	2006-01-09 16:40:00 UTC (rev 2870)
@@ -1014,10 +1014,11 @@
 
 #undef MEMBER_BODY
 
-#define ASSOC_BODY(obj, alist, cmp, pair, key)                               \
+#define ASSOC_BODY(obj, alist, cmp)                                          \
     do {                                                                     \
-        for (alist = alist; CONSP(alist); alist = CDR(alist)) {              \
-            pair = CAR(alist);                                               \
+        ScmObj pair, key;                                                    \
+                                                                             \
+        FOR_EACH (pair, alist) {                                             \
             ENSURE_CONS(pair);                                               \
             key = CAR(pair);                                                 \
             if (cmp(key, obj))                                               \
@@ -1030,32 +1031,29 @@
 ScmObj
 scm_p_assq(ScmObj obj, ScmObj alist)
 {
-    ScmObj pair, key;
     DECLARE_FUNCTION("assq", procedure_fixed_2);
 
-    ASSOC_BODY(obj, alist, EQ, pair, key);
+    ASSOC_BODY(obj, alist, EQ);
 }
 
 ScmObj
 scm_p_assv(ScmObj obj, ScmObj alist)
 {
-    ScmObj pair, key;
     DECLARE_FUNCTION("assv", procedure_fixed_2);
 
 #if (SCM_HAS_IMMEDIATE_INT && SCM_HAS_IMMEDIATE_CHAR)
-    ASSOC_BODY(obj, alist, EQ, pair, key);
+    ASSOC_BODY(obj, alist, EQ);
 #else
-    ASSOC_BODY(obj, alist, EQVP, pair, key);
+    ASSOC_BODY(obj, alist, EQVP);
 #endif
 }
 
 ScmObj
 scm_p_assoc(ScmObj obj, ScmObj alist)
 {
-    ScmObj pair, key;
     DECLARE_FUNCTION("assoc", procedure_fixed_2);
 
-    ASSOC_BODY(obj, alist, EQUALP, pair, key);
+    ASSOC_BODY(obj, alist, EQUALP);
 }
 
 #undef ASSOC_BODY
@@ -1515,8 +1513,8 @@
 
     /* TODO: make efficient */
     sport = scm_p_srfi6_open_output_string();
-    for (rest = lst; CONSP(rest); rest = CDR(rest)) {
-        ch = CAR(rest);
+    rest = lst;
+    FOR_EACH (ch, rest) {
         ENSURE_CHAR(ch);
         scm_port_put_char(sport, SCM_CHAR_VALUE(ch));
     }

Modified: branches/r5rs/sigscheme/storage-symbol.c
===================================================================
--- branches/r5rs/sigscheme/storage-symbol.c	2006-01-09 16:03:46 UTC (rev 2869)
+++ branches/r5rs/sigscheme/storage-symbol.c	2006-01-09 16:40:00 UTC (rev 2870)
@@ -71,12 +71,13 @@
 {
     ScmObj sym, lst, rest;
     int hash;
+    DECLARE_INTERNAL_FUNCTION("scm_intern");
 
     hash = symbol_name_hash(name);
     lst = scm_symbol_hash[hash];
 
-    for (rest = lst; CONSP(rest); rest = CDR(rest)) {
-        sym = CAR(rest);
+    rest = lst;
+    FOR_EACH (sym, rest) {
         if (strcmp(SCM_SYMBOL_NAME(sym), name) == 0)
             return sym;
     }
@@ -92,12 +93,13 @@
 ScmObj
 scm_symbol_bound_to(ScmObj obj)
 {
+    ScmObj lst, sym, val;
     int i;
-    ScmObj lst, sym, val;
+    DECLARE_INTERNAL_FUNCTION("scm_symbol_bound_to");
 
     for (i = 0; i < NAMEHASH_SIZE; i++) {
-        for (lst = scm_symbol_hash[i]; CONSP(lst); lst = CDR(lst)) {
-            sym = CAR(lst);
+        lst = scm_symbol_hash[i];
+        FOR_EACH (sym, lst) {
             val = SCM_SYMBOL_VCELL(sym);
             if (!EQ(val, SCM_UNBOUND) && EQ(val, obj))
                 return sym;



More information about the uim-commit mailing list