[tarantool-patches] Re: [PATCH 2/7] lua: implement string.u_count
Alexander Turenko
alexander.turenko at tarantool.org
Sat Apr 28 04:10:56 MSK 2018
Just one tiny comment below.
WBR, Alexander Turenko.
On Thu, Apr 26, 2018 at 02:29:02AM +0300, Vladislav Shpilevoy wrote:
> Lua can not calculate length of a unicode string correctly. But
> Tarantool has ICU on board - lets use it to calculate length.
>
> u_count has options, that allows to count only symbols of a
> specific class, for example, only capital letters, or digits.
> Options can be combined.
>
> Closes #3081
> ---
> extra/exports | 1 +
> src/CMakeLists.txt | 1 +
> src/lua/string.lua | 52 ++++++++++++++++++++++++++++++++++++++++++++
> src/util.c | 48 +++++++++++++++++++++++++++++++++++++++-
> test/app-tap/string.test.lua | 22 ++++++++++++++++++-
> 5 files changed, 122 insertions(+), 2 deletions(-)
>
> <...>
> diff --git a/src/util.c b/src/util.c
> index 9458695b9..c117dee05 100644
> --- a/src/util.c
> +++ b/src/util.c
> <...>
> +/**
> + * Get length of a UTF8 string.
> + * @param s UTF8 string.
> + * @param bsize Binary size of @an s.
Whether it worth to clarify that it is w/o trailing '\0'?
> + * @param flags Binary OR of u_count_class flags.
> + * @retval >=0 Count of symbols matched one of @a flags.
> + * @retval <0 Invalid UTF8 on the position -1 * returned value.
> + */
> +int
> +u_count(const char *s, int bsize, uint8_t flags)
> +{
More information about the Tarantool-patches
mailing list