From c338e47fbef2ce1354acbd9f521196dea3fe93f5 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 30 Jul 2009 13:41:21 -0700 Subject: [PATCH] svec: New convenience macro SVEC_FOR_EACH. --- lib/svec.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/svec.h b/lib/svec.h index 7d8777fa..e1736bc6 100644 --- a/lib/svec.h +++ b/lib/svec.h @@ -57,4 +57,13 @@ char *svec_join(const struct svec *, const char *svec_back(const struct svec *); void svec_pop_back(struct svec *); +/* Iterates over the names in SVEC, assigning each name in turn to NAME and its + * index to INDEX. */ +#define SVEC_FOR_EACH(INDEX, NAME, SVEC) \ + for ((INDEX) = 0; \ + ((INDEX) < (SVEC)->n \ + ? (NAME) = (SVEC)->names[INDEX], 1 \ + : 0); \ + (INDEX)++) + #endif /* svec.h */ -- 2.30.2