@@@ better tests
[mLib] / utils / control.h
index 433d57b..fdc7125 100644 (file)
  * from the correspondingly tagged statement, and continues with the
  * following statement again.
  */
-#define FIRSTBRANCH(tag)       if (1) MCTRL__LABEL(tag): {
-#define MIDBRANCH(tag)         } else if (0) MCTRL__LABEL(tag): {
-#define LASTBRANCH(tag)                } else MCTRL__LABEL(tag):
-#define GOBRANCH(tag)          goto MCTRL__LABEL(tag)
+#define FIRSTBRANCH(tag)  if (1) { goto MCTRL__LABEL(tag); MCTRL__LABEL(tag):
+#define MIDBRANCH(tag)    } else if (0) MCTRL__LABEL(tag): {
+#define LASTBRANCH(tag)   } else MCTRL__LABEL(tag):
+#define GOBRANCH(tag)     goto MCTRL__LABEL(tag)
 
 /* @BEFORE(tag, stmt_0) stmt_1@
  *
@@ -78,8 +78,9 @@
  */
 #define AFTER(tag, stmt)                                               \
        if (1) goto MCTRL__LABEL(tag##__after_body);                    \
+       else if (1) { MCTRL__LABEL(tag##__after_end): stmt }            \
        else for (;;)                                                   \
-         if (1) { stmt break; }                                        \
+         if (1) goto MCTRL__LABEL(tag##__after_end);                   \
          else MCTRL__LABEL(tag##__after_body):
 
 /* @WRAP(tag, before, onend, onbreak) stmt@
@@ -92,8 +93,8 @@
  */
 #define WRAP(tag, before, onend, onbreak)                              \
        if (1) { before goto MCTRL__LABEL(tag##__wrap_body); }          \
-       else if (1) MCTRL__LABEL(tag##__wrap_end): onend                \
-       else if (1) MCTRL__LABEL(tag##__wrap_break): onbreak            \
+       else if (1) { MCTRL__LABEL(tag##__wrap_end): onend }            \
+       else if (1) { MCTRL__LABEL(tag##__wrap_break): onbreak }        \
        else for (;;)                                                   \
          if (1) goto MCTRL__LABEL(tag##__wrap_break);                  \
          else for (;;)                                                 \
 #define ALLOWELSE(tag, before, onend, onbreak)                         \
        if (1) goto MCTRL__LABEL(tag##__allowelse_body);                \
        else if (1) MCTRL__LABEL(tag##__allowelse_body_end): ;          \
-       else if (1) MCTRL__LABEL(tag##__allowelse_else_end): onend      \
-       else if (1) MCTRL__LABEL(tag##__allowelse_else_break): onbreak  \
-       else if (1) MCTRL__LABEL(tag##__allowelse_before_else):         \
-         { before goto MCTRL__LABEL(tag##__allowelse_else); }          \
-       else for (;;)                                                   \
+       else if (1) { MCTRL__LABEL(tag##__allowelse_else_end): onend }  \
+       else if (1) { MCTRL__LABEL(tag##__allowelse_else_break): onbreak } \
+       else if (1) {                                                   \
+       MCTRL__LABEL(tag##__allowelse_before_else):                     \
+         before goto MCTRL__LABEL(tag##__allowelse_else);              \
+       } else for (;;)                                                 \
          if (1) goto MCTRL__LABEL(tag##__allowelse_else_break);        \
          else for (;;)                                                 \
            if (1) goto MCTRL__LABEL(tag##__allowelse_else_end);        \