From 66f5e6c67d1682d53e1969c39248443ac958cca9 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 18 Mar 2023 17:56:44 +0100 Subject: [PATCH] Support for more than one expression in M_DEFER --- m-core.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/m-core.h b/m-core.h index fc066bef..1afa3502 100644 --- a/m-core.h +++ b/m-core.h @@ -4245,14 +4245,14 @@ m_core_parse2_enum (const char str[], const char **endptr) // code using p } // Here p is free */ -#define M_DEFER(clear) \ - M_DEFER_INTERNAL(clear, m_var_ ## __LINE__) +#define M_DEFER(...) \ + M_DEFER_INTERNAL(m_var_ ## __LINE__, __VA_ARGS__) -#define M_DEFER_INTERNAL(clear, cont) \ +#define M_DEFER_INTERNAL(cont, ...) \ for(bool cont = true; cont; cont = false) \ - M_DEFER_TRY_INJECT_PRE(cont, clear) \ - for( (void) 0; cont ; (clear), cont = false) \ - M_DEFER_TRY_INJECT_POST(cont, clear) \ + M_DEFER_TRY_INJECT_PRE(cont, __VA_ARGS__) \ + for( (void) 0; cont ; (__VA_ARGS__), cont = false) \ + M_DEFER_TRY_INJECT_POST(cont, __VA_ARGS__) \ for( (void) 0; cont; cont = false) // Theses macros will be overrided by m-try if needed. @@ -4279,7 +4279,7 @@ m_core_parse2_enum (const char str[], const char **endptr) #define M_LET_IF_INTERNAL(init, test, clear, else_a, cont) \ for(bool cont = true; cont; cont = false) \ for( init ; cont && ( (test) || (else_a, false) ); cont = false) \ - M_DEFER_INTERNAL(clear, M_C(cont, defer) ) + M_DEFER_INTERNAL(M_C(cont, defer), clear )