]> granicus.if.org Git - yasm/commitdiff
Reverse how traverse functions do early termination (now, they terminate on
authorPeter Johnson <peter@tortall.net>
Wed, 20 Feb 2002 07:38:41 +0000 (07:38 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 20 Feb 2002 07:38:41 +0000 (07:38 -0000)
a non-zero func return and return the value func returned).  Document the
changes in the header files.

svn path=/trunk/yasm/; revision=468

libyasm/bytecode.c
libyasm/bytecode.h
libyasm/section.c
libyasm/section.h
src/bytecode.c
src/bytecode.h
src/section.c
src/section.h

index f9e6fb6ff728e29246db998219fa5394d7218547..7c00a1bd61fdf9056e31e013ebda1ec0ec362865 100644 (file)
@@ -520,10 +520,12 @@ bcs_traverse(bytecodehead *headp, void *d,
 {
     bytecode *cur;
 
-    STAILQ_FOREACH(cur, headp, link)
-       if (func(cur, d) == 0)
-           return 0;
-    return 1;
+    STAILQ_FOREACH(cur, headp, link) {
+       int retval = func(cur, d);
+       if (retval != 0)
+           return retval;
+    }
+    return 0;
 }
 
 dataval *
index f4c46927f9689bbb4aaf9317b9624f99ed900757..eb8ec1c5362b609ef8c1187f10e95d04b8c978a8 100644 (file)
@@ -95,6 +95,12 @@ void bcs_delete(bytecodehead *headp);
 
 void bcs_print(FILE *f, const bytecodehead *headp);
 
+/* Calls func for each bytecode in the linked list of bytecodes pointed to by
+ * headp.  The data pointer d is passed to each func call.
+ *
+ * Stops early (and returns func's return value) if func returns a nonzero
+ * value.  Otherwise returns 0.
+ */
 int bcs_traverse(bytecodehead *headp, /*@null@*/ void *d,
                 int (*func) (bytecode *bc, /*@null@*/ void *d));
 
index f0c2f0d633b5295e34e15cf528d11df019dd0345..7e398006284c1a3a6cdca4e3ae2a0027d2f694fb 100644 (file)
@@ -193,10 +193,12 @@ sections_traverse(sectionhead *headp, /*@null@*/ void *d,
 {
     section *cur;
     
-    STAILQ_FOREACH(cur, headp, link)
-       if (func(cur, d) == 0)
-           return 0;
-    return 1;
+    STAILQ_FOREACH(cur, headp, link) {
+       int retval = func(cur, d);
+       if (retval != 0)
+           return retval;
+    }
+    return 0;
 }
 
 bytecodehead *
index 153490eca0c76a244df24e90e4329b6789736a74..17cbff82955c78ae4c8d5cdfbec163245c83bab0 100644 (file)
@@ -45,6 +45,12 @@ void sections_delete(sectionhead *headp);
 
 void sections_print(FILE *f, const sectionhead *headp);
 
+/* Calls func for each section in the linked list of sections pointed to by
+ * headp.  The data pointer d is passed to each func call.
+ *
+ * Stops early (and returns func's return value) if func returns a nonzero
+ * value.  Otherwise returns 0.
+ */
 int sections_traverse(sectionhead *headp, /*@null@*/ void *d,
                      int (*func) (section *sect, /*@null@*/ void *d));
 
index f9e6fb6ff728e29246db998219fa5394d7218547..7c00a1bd61fdf9056e31e013ebda1ec0ec362865 100644 (file)
@@ -520,10 +520,12 @@ bcs_traverse(bytecodehead *headp, void *d,
 {
     bytecode *cur;
 
-    STAILQ_FOREACH(cur, headp, link)
-       if (func(cur, d) == 0)
-           return 0;
-    return 1;
+    STAILQ_FOREACH(cur, headp, link) {
+       int retval = func(cur, d);
+       if (retval != 0)
+           return retval;
+    }
+    return 0;
 }
 
 dataval *
index f4c46927f9689bbb4aaf9317b9624f99ed900757..eb8ec1c5362b609ef8c1187f10e95d04b8c978a8 100644 (file)
@@ -95,6 +95,12 @@ void bcs_delete(bytecodehead *headp);
 
 void bcs_print(FILE *f, const bytecodehead *headp);
 
+/* Calls func for each bytecode in the linked list of bytecodes pointed to by
+ * headp.  The data pointer d is passed to each func call.
+ *
+ * Stops early (and returns func's return value) if func returns a nonzero
+ * value.  Otherwise returns 0.
+ */
 int bcs_traverse(bytecodehead *headp, /*@null@*/ void *d,
                 int (*func) (bytecode *bc, /*@null@*/ void *d));
 
index f0c2f0d633b5295e34e15cf528d11df019dd0345..7e398006284c1a3a6cdca4e3ae2a0027d2f694fb 100644 (file)
@@ -193,10 +193,12 @@ sections_traverse(sectionhead *headp, /*@null@*/ void *d,
 {
     section *cur;
     
-    STAILQ_FOREACH(cur, headp, link)
-       if (func(cur, d) == 0)
-           return 0;
-    return 1;
+    STAILQ_FOREACH(cur, headp, link) {
+       int retval = func(cur, d);
+       if (retval != 0)
+           return retval;
+    }
+    return 0;
 }
 
 bytecodehead *
index 153490eca0c76a244df24e90e4329b6789736a74..17cbff82955c78ae4c8d5cdfbec163245c83bab0 100644 (file)
@@ -45,6 +45,12 @@ void sections_delete(sectionhead *headp);
 
 void sections_print(FILE *f, const sectionhead *headp);
 
+/* Calls func for each section in the linked list of sections pointed to by
+ * headp.  The data pointer d is passed to each func call.
+ *
+ * Stops early (and returns func's return value) if func returns a nonzero
+ * value.  Otherwise returns 0.
+ */
 int sections_traverse(sectionhead *headp, /*@null@*/ void *d,
                      int (*func) (section *sect, /*@null@*/ void *d));