[Tarantool-patches] [RFC 1/4] cfg: add cfg_isnumber helper
Serge Petrenko
sergepetrenko at tarantool.org
Fri Nov 20 12:53:37 MSK 2020
19.11.2020 22:40, Cyrill Gorcunov пишет:
> We will need it to figure out if parameter
> is a numeric value when doing configuration
> check.
>
> Part-of #5446
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
> ---
> src/cfg.c | 9 +++++++++
> src/cfg.h | 6 ++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/src/cfg.c b/src/cfg.c
> index 46cff1999..cf07d5817 100644
> --- a/src/cfg.c
> +++ b/src/cfg.c
> @@ -57,6 +57,15 @@ cfg_geti(const char *param)
> return val;
> }
>
> +bool
> +cfg_isnumber(const char *param)
> +{
> + cfg_get(param);
> + bool ret = !!lua_isnumber(tarantool_L, -1);
> + lua_pop(tarantool_L, 1);
> + return ret;
> +}
> +
> int
> cfg_getb(const char *param)
> {
> diff --git a/src/cfg.h b/src/cfg.h
> index 140bdddb8..e2955e6b2 100644
> --- a/src/cfg.h
> +++ b/src/cfg.h
> @@ -40,6 +40,12 @@ extern "C" {
> int
> cfg_geti(const char *param);
>
> +/**
> + * Test if cfg parameter is a number.
> + */
> +bool
> +cfg_isnumber(const char *param);
> +
> /**
> * Gets boolean parameter of cfg.
> * Returns -1 in case of nil
LGTM.
--
Serge Petrenko
More information about the Tarantool-patches
mailing list