]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
FOREACH_WORD
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 7 Nov 2015 10:12:51 +0000 (21:12 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 7 Nov 2015 10:12:51 +0000 (21:12 +1100)
qcsrc/lib/iter.qh

index b0a602c963b9d834b89afafd7eb9352c98fb0f57..f3214a24865afe3af5ca5c3554777be9dacb122b 100644 (file)
@@ -5,21 +5,34 @@
        do \
        { \
                for (int i = start; i < end; ++i) \
-               {                 \
-                       const noref entity it = arr[i];                 \
-                       if (cond) { body }                              \
-               }                                                   \
+               { \
+                       const noref entity it = arr[i]; \
+                       if (cond) { body } \
+               } \
        } \
        while (0)
 
 #define FOREACH_LIST(list, next, cond, body) \
        do \
-       {               \
-               noref int i = 0;                                            \
+       { \
+               int i = 0; \
                for (entity it = list##_first; it; (it = it.next, ++i)) \
-               {   \
-                       if (cond) { body }                                      \
-               }                                                           \
+               { \
+                       if (cond) { body } \
+               } \
+       } \
+       while (0)
+
+#define FOREACH_WORD(words, cond, body) \
+       do \
+       { \
+               string _words = words; \
+               int i = 0; \
+               for (string _it; (_it = car(_words)); (_words = cdr(_words), ++i)) \
+               { \
+                       const noref string it = _it; \
+                       if (cond) { body } \
+               } \
        } \
        while (0)