summaryrefslogtreecommitdiff
path: root/lib/glcontainers.h
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2019-01-27 14:02:55 +0000
committerColin Watson <cjwatson@debian.org>2019-01-27 14:02:55 +0000
commitf41470b925fa2d0eb94bd800af994ce77e1896d4 (patch)
tree8052f75a72e19236700d656f6c2f9e5404effa5c /lib/glcontainers.h
parent1f098154c430bcdb3f6e7d32e7a5fb4ea7e57b0d (diff)
Use macros for common cases of list iteration
* lib/glcontainers.h (GL_LIST_FOREACH_START, GL_LIST_FOREACH_END): New macros. * src/catman.c (main): Replace manual list iteration with equivalent macros. * src/man.c (do_global_apropos, locate_page_in_manpath): Likewise. * src/mandb.c (main): Likewise. * src/manp.c (get_config, print_list, get_sections, def_path, get_manpath_from_path, create_pathlist, get_mandb_manpath, get_catpath, is_global_mandir): Likewise. * src/whatis.c (search): Likewise. * src/zsoelim.l (zsoelim_open_file): Likewise.
Diffstat (limited to 'lib/glcontainers.h')
-rw-r--r--lib/glcontainers.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/glcontainers.h b/lib/glcontainers.h
index 0c1385a7..482a99d3 100644
--- a/lib/glcontainers.h
+++ b/lib/glcontainers.h
@@ -34,4 +34,14 @@ bool string_equals (const void *s1, const void *s2);
size_t string_hash (const void *s);
void plain_free (const void *s);
+#define GL_LIST_FOREACH_START(list, item) \
+ do { \
+ gl_list_iterator_t list##_iter = gl_list_iterator (list); \
+ while (gl_list_iterator_next (&list##_iter, \
+ (const void **) &item, NULL))
+
+#define GL_LIST_FOREACH_END(list) \
+ gl_list_iterator_free (&list##_iter); \
+ } while (0)
+
#endif /* MAN_GLCONTAINERS_H */