]> granicus.if.org Git - yasm/commitdiff
Match yasm_symtab_traverse() implementation to doxygen documentation by
authorPeter Johnson <peter@tortall.net>
Sun, 5 Feb 2006 22:49:10 +0000 (22:49 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 5 Feb 2006 22:49:10 +0000 (22:49 -0000)
fixing underlying HAMT implementation to match.  Change is to reflect that
traversal stops when subfunction return is nonzero.

* hamt.h (HAMT_traverse): Update doxygen comment for stop on nonzero instead
of stop on zero.
* hamt.c (HAMT_traverse): Implement.
* symrec.c, xdf-objfmt.c, elf-objfmt.c, coff-objfmt.c: Update return values
for subfunctions.

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

libyasm/hamt.c
libyasm/hamt.h
libyasm/symrec.c
modules/objfmts/coff/coff-objfmt.c
modules/objfmts/elf/elf-objfmt.c
modules/objfmts/xdf/xdf-objfmt.c

index 6290e3ee748be57b6189bc2c13ff40ec345c957f..f93c51b0e8601666e509cfa9b59e1e47c08143fb 100644 (file)
@@ -150,10 +150,12 @@ HAMT_traverse(HAMT *hamt, void *d,
                            /*@null@*/ void *d))
 {
     HAMTEntry *entry;
-    STAILQ_FOREACH(entry, &hamt->entries, next)
-       if (func(entry->data, d) == 0)
-           return 0;
-    return 1;
+    STAILQ_FOREACH(entry, &hamt->entries, next) {
+       int retval = func(entry->data, d);
+       if (retval != 0)
+           return retval;
+    }
+    return 0;
 }
 
 /*@-temptrans -kepttrans -mustfree@*/
index 7a6e7f3a32bda5546c263b9c70ef1f8fdbaee230..78d380e705283e0499ef997a7b7d813e2bf66d30 100644 (file)
@@ -81,11 +81,11 @@ void HAMT_destroy(/*@only@*/ HAMT *hamt,
 /*@dependent@*/ /*@null@*/ void *HAMT_search(HAMT *hamt, const char *str);
 
 /** Traverse over all keys in HAMT, calling function on each data item. 
- * Stops early if func returns 0.
  * \param hamt         Hash array mapped trie
  * \param d            Data to pass to each call to func.
  * \param func         Function to call
- * \return 0 if stopped early, 1 if all data items were traversed.
+ * \return Stops early (and returns func's return value) if func returns a
+ *        nonzero value; otherwise 0.
  */
 int HAMT_traverse(HAMT *hamt, /*@null@*/ void *d,
                  int (*func) (/*@dependent@*/ /*@null@*/ void *node,
index b2b94bb1a0c1a318889fdde975a830d1549b53fd..c7786efdf657e8ef1be610a0c583ae7ada95f8de 100644 (file)
@@ -166,8 +166,6 @@ symtab_get_or_new(yasm_symtab *symtab, const char *name, int in_table)
 }
 /*@=freshtrans =mustfree@*/
 
-/* Call a function with each symrec.  Stops early if 0 returned by func.
-   Returns 0 if stopped early. */
 int
 yasm_symtab_traverse(yasm_symtab *symtab, void *d,
                     int (*func) (yasm_symrec *sym, void *d))
@@ -313,7 +311,7 @@ symtab_parser_finalize_checksym(yasm_symrec *sym, /*@null@*/ void *d)
        }
     }
 
-    return 1;
+    return 0;
 }
 
 void
@@ -358,7 +356,7 @@ symrec_print_wrapper(yasm_symrec *sym, /*@null@*/ void *d)
     assert(data != NULL);
     fprintf(data->f, "%*sSymbol `%s'\n", data->indent_level, "", sym->name);
     yasm_symrec_print(sym, data->f, data->indent_level+1);
-    return 1;
+    return 0;
 }
 
 void
index 0ef6b323e56042a4cb7f46bbe4abb214da844891..d0ed68c393e27d03899657c77fa2239741cd607c 100644 (file)
@@ -765,7 +765,7 @@ coff_objfmt_count_sym(yasm_symrec *sym, /*@null@*/ void *d)
 
        info->indx += sym_data->numaux + 1;
     }
-    return 1;
+    return 0;
 }
 
 static int
@@ -906,7 +906,7 @@ coff_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d)
            fwrite(info->buf, 18, 1, info->f);
        }
     }
-    return 1;
+    return 0;
 }
 
 static int
@@ -942,7 +942,7 @@ coff_objfmt_output_str(yasm_symrec *sym, /*@null@*/ void *d)
            }
        }
     }
-    return 1;
+    return 0;
 }
 
 static void
index 340e938d6e2702e9ec3e7f17521bbbfe326f96f2..f6dbd0ef1e31076d19d47db0b206585cebf39299 100644 (file)
@@ -123,7 +123,7 @@ elf_objfmt_append_local_sym(yasm_symrec *sym, /*@null@*/ void *d)
     assert(info != NULL);
 
     if (!yasm_symrec_get_label(sym, &precbc))
-       return 1;
+       return 0;
     sect = yasm_bc_get_section(precbc);
 
     entry = yasm_symrec_get_data(sym, &elf_symrec_data);
@@ -147,14 +147,14 @@ elf_objfmt_append_local_sym(yasm_symrec *sym, /*@null@*/ void *d)
        yasm_symrec_add_data(sym, &elf_symrec_data, entry);
 
        if (is_sect)
-           return 1;
+           return 0;
     }
 
     if (precbc)
        value = precbc->offset + precbc->len;
     elf_symtab_set_nonzero(entry, sect, 0, 0, 0, NULL, &value);
 
-    return 1;
+    return 0;
 }
 
 static yasm_objfmt *
index 8faa4432426893de1d3b8b7286dc0aa2fe08908f..703de1a675641c9960629fdf53feb94f6c13d4c8 100644 (file)
@@ -476,7 +476,7 @@ xdf_objfmt_count_sym(yasm_symrec *sym, /*@null@*/ void *d)
 
        info->indx++;
     }
-    return 1;
+    return 0;
 }
 
 static int
@@ -565,7 +565,7 @@ xdf_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d)
        YASM_WRITE_32_L(localbuf, flags);       /* flags */
        fwrite(info->buf, 16, 1, info->f);
     }
-    return 1;
+    return 0;
 }
 
 static int
@@ -581,7 +581,7 @@ xdf_objfmt_output_str(yasm_symrec *sym, /*@null@*/ void *d)
        size_t len = strlen(name);
        fwrite(name, len+1, 1, info->f);
     }
-    return 1;
+    return 0;
 }
 
 static void