From a0e9ddf58943171a9031159919e99ef20147a11e Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 4 Jun 2014 11:53:34 +0000 Subject: [PATCH] Convert esl_true and esl_false to functions Prior to this commit, an expression such as: esl_true("true") ? 42 : 0 ...would return 1 rather than 42. --- libs/esl/src/include/esl_config.h | 34 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/libs/esl/src/include/esl_config.h b/libs/esl/src/include/esl_config.h index 0a2dffb42a..34c67ca219 100644 --- a/libs/esl/src/include/esl_config.h +++ b/libs/esl/src/include/esl_config.h @@ -81,28 +81,30 @@ extern "C" { \param expr a string expression \return true or false */ -#define esl_true(expr)\ -(expr && ( !strcasecmp(expr, "yes") ||\ -!strcasecmp(expr, "on") ||\ -!strcasecmp(expr, "true") ||\ -!strcasecmp(expr, "enabled") ||\ -!strcasecmp(expr, "active") ||\ -!strcasecmp(expr, "allow") ||\ -atoi(expr))) ? 1 : 0 +static inline int esl_true(const char *expr) { + return (expr && (!strcasecmp(expr, "yes") + || !strcasecmp(expr, "on") + || !strcasecmp(expr, "true") + || !strcasecmp(expr, "enabled") + || !strcasecmp(expr, "active") + || !strcasecmp(expr, "allow") + || atoi(expr))); +} /*! \brief Evaluate the falsefullness of a string expression \param expr a string expression \return true or false */ -#define esl_false(expr)\ -(expr && ( !strcasecmp(expr, "no") ||\ -!strcasecmp(expr, "off") ||\ -!strcasecmp(expr, "false") ||\ -!strcasecmp(expr, "disabled") ||\ -!strcasecmp(expr, "inactive") ||\ -!strcasecmp(expr, "disallow") ||\ -!atoi(expr))) ? 1 : 0 +static inline int esl_false(const char *expr) { + return (expr && (!strcasecmp(expr, "no") + || !strcasecmp(expr, "off") + || !strcasecmp(expr, "false") + || !strcasecmp(expr, "disabled") + || !strcasecmp(expr, "inactive") + || !strcasecmp(expr, "disallow") + || !atoi(expr))); +} typedef struct esl_config esl_config_t;