diff options
author | Colin Watson <cjwatson@debian.org> | 2022-01-01 02:33:27 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2022-01-01 02:33:27 +0000 |
commit | 9740c56b311f863f295b84cf93aee84379d0740b (patch) | |
tree | 06c879f650250f30902e70508ffa021cbd122bf8 /lib/Makefile.am | |
parent | 5c28907556920624e6a257b1aeaaa91501306ed8 (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 'lib/Makefile.am')
-rw-r--r-- | lib/Makefile.am | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index e5bd626c..62bce086 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -43,6 +43,7 @@ libman_la_SOURCES = \ glcontainers.h \ linelength.c \ linelength.h \ + mp.h \ orderfiles.c \ orderfiles.h \ pathsearch.c \ |