From b2d3d86e0c8d32ae2ef3f717f19c85c6e8193343 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Wed, 3 Nov 2021 20:54:03 +0100 Subject: [PATCH] Add alternative macro M_TEST_METHOD_ALTER_P --- README.md | 3 +++ m-core.h | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0004b1bf..42681707 100644 --- a/README.md +++ b/README.md @@ -6378,8 +6378,11 @@ Theses new operators will have higher priority than the ones in the given oplist. ##### M\_TEST\_METHOD\_P(method, oplist) +##### M\_TEST\_METHOD\_ALTER\_P(method, oplist) Test if a method is present in an oplist. Return 0 or 1. +M\_TEST\_METHOD\_P does not work if the returned method is something within parenthesis (like OPLIST*) +If this case is possible, you shall use the M_TEST_METHOD_ALTER_P macro (safer but slower). ##### M\_IF\_METHOD(method, oplist) diff --git a/m-core.h b/m-core.h index b2455953..d75be48b 100644 --- a/m-core.h +++ b/m-core.h @@ -3336,11 +3336,16 @@ m_core_parse2_enum (const char str[], const char **endptr) /* Test if a method is present in an oplist. Return 0 (method is absent or disabled) or 1 (method is present and not disabled). - NOTE: Does not work if method is OPLIST, KEY_OPLIST or VALUE_OPLIST. + NOTE: M_TEST_METHOD_P does not work if method is something within parenthesis (like OPLIST*) + In this case, you shall use the M_TEST_METHOD_ALTER_P macro (safer but slower). */ #define M_TEST_METHOD_P(method, oplist) \ M_BOOL(M_GET_METHOD (method, 0, M_OPFLAT oplist)) +#define M_TEST_METHOD_ALTER_P(method, oplist) \ + M_INV(M_EMPTY_P(M_GET_METHOD (method, , M_OPFLAT oplist))) + + /* Test if a method is disabled in an oplist. To disable an oplist, just put '0' in the method like this: Example: (INIT(0), CLEAR(clear))