summaryrefslogtreecommitdiff
path: root/libdb/db_delete.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2022-01-01 02:33:27 +0000
committerColin Watson <cjwatson@debian.org>2022-01-01 02:33:27 +0000
commit9740c56b311f863f295b84cf93aee84379d0740b (patch)
tree06c879f650250f30902e70508ffa021cbd122bf8 /libdb/db_delete.c
parent5c28907556920624e6a257b1aeaaa91501306ed8 (diff)
Simplify interface to container iterator macros
The Gnulib container iterator macros (GL_LIST_FOREACH_* and GL_MAP_FOREACH_*) have to run code both before and after a chunk of user-supplied code. This previously required a START/END macro pair used something like this: GL_LIST_FOREACH_START (names, name) { ... } GL_LIST_FOREACH_END (names); This doesn't look natural in C, and so it was easy to get it wrong. It's possible to do better, at the cost of some tricky macros. Fortunately, Simon Tatham has already done the hard work in https://www.chiark.greenend.org.uk/~sgtatham/mp/, and the necessary header file is MIT-licensed, so we can incorporate it. Now these iterator macros are used more like this, which is a much more natural C style: GL_LIST_FOREACH (names, name) { ... } * lib/mp.h: New file. * lib/Makefile.am (libman_la_SOURCES): Add mp.h. * lib/README: Add mp.h. Rephrase introductory text about licensing to account for an MIT-licensed file. * lib/glcontainers.h (GL_LIST_FOREACH_START, GL_LIST_FOREACH_END): Rewrite as ... (GL_LIST_FOREACH): ... this. Update all callers. (GL_MAP_FOREACH_START, GL_MAP_FOREACH_END): Rewrite as ... (GL_MAP_FOREACH): ... this. Update all callers. * NEWS, README.md, docs/HACKING: Document C99 compiler requirement.
Diffstat (limited to 'libdb/db_delete.c')
-rw-r--r--libdb/db_delete.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/libdb/db_delete.c b/libdb/db_delete.c
index 24ce1d83..2e4534e0 100644
--- a/libdb/db_delete.c
+++ b/libdb/db_delete.c
@@ -122,12 +122,11 @@ int dbdelete (MYDBM_FILE dbf, const char *name, struct mandata *info)
}
/* create our new multi content */
- GL_LIST_FOREACH_START (refs, ref)
+ GL_LIST_FOREACH (refs, ref)
multi_content = appendstr (multi_content,
"\t", ref->name,
"\t", ref->ext,
(void *) 0);
- GL_LIST_FOREACH_END (refs);
MYDBM_FREE_DPTR (cont);
MYDBM_SET (cont, multi_content);