-extern void bitset_dump PARAMS ((FILE *, bitset));
-
-/* Loop over all elements of BSET, starting with MIN, executing CODE. */
-#define BITSET_EXECUTE(BSET, MIN, N, CODE) \
-do { \
- bitset_bindex _list[BITSET_LIST_SIZE]; \
- bitset_bindex _next = (MIN); \
- int _num; \
- \
- while ((_num = bitset_list ((BSET), _list, BITSET_LIST_SIZE, &_next)))\
- { \
- int _i; \
- \
- for (_i = 0; _i < _num; _i++) \
- { \
- (N) = _list[_i]; \
- CODE; \
- } \
- if (_num < BITSET_LIST_SIZE) \
- break; \
- } \
-} while (0)
+extern void bitset_dump (FILE *, bitset);
+
+/* Loop over all elements of BSET, starting with MIN, setting INDEX
+ to the index of each set bit. For example, the following will print
+ the bits set in a bitset:
+
+ bitset_bindex i;
+ bitset_iterator iter;
+
+ BITSET_FOR_EACH (iter, src, i, 0)
+ {
+ printf ("%lu ", (unsigned long int) i);
+ };
+*/
+#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
+ for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
+ (ITER.num == BITSET_LIST_SIZE) \
+ && (ITER.num = bitset_list (BSET, ITER.list, \
+ BITSET_LIST_SIZE, &ITER.next));) \
+ for (ITER.i = 0; \
+ ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
+ ITER.i++)