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 /docs | |
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 'docs')
-rw-r--r-- | docs/HACKING | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/docs/HACKING b/docs/HACKING index e81a3200..59ac6f2e 100644 --- a/docs/HACKING +++ b/docs/HACKING @@ -76,10 +76,7 @@ If you're calling any of the is*() or to*() functions in <ctype.h>, please do so via the CTYPE() macro in include/manconfig.h to ensure that the argument type is correct. -You may assume C89 (e.g. no need to support K&R-style function definitions), -but please do not assume C99 (e.g. do not use nested functions or // -comments). However, it's OK to use C99 runtime facilities that are provided -by Gnulib, such as <stdbool.h>. +You may assume C99. Testing |