Re: [hackers] [[dwm][PATCH]] drw / utf8decode : simpler is better ?

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Tue, 16 Aug 2022 00:00:52 +0200

On Tue, Jul 19, 2022 at 04:38:34PM +0200, nenesses wrote:
> ---
> drw.c | 15 +++------------
> 1 file changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/drw.c b/drw.c
> index ced7d37..b6073a4 100644
> --- a/drw.c
> +++ b/drw.c
> _AT_@ -25,16 +25,6 @@ utf8decodebyte(const char c, size_t *i)
> return 0;
> }
>
> -static size_t
> -utf8validate(long *u, size_t i)
> -{
> - if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
> - *u = UTF_INVALID;
> - for (i = 1; *u > utfmax[i]; ++i)
> - ;
> - return i;
> -}
> -
> static size_t
> utf8decode(const char *c, long *u, size_t clen)
> {
> _AT_@ -54,8 +44,9 @@ utf8decode(const char *c, long *u, size_t clen)
> }
> if (j < len)
> return 0;
> - *u = udecoded;
> - utf8validate(u, len);
> +
> + *u = (!BETWEEN(udecoded, utfmin[i], utfmax[i]) || BETWEEN(udecoded, 0xD800, 0xDFFF))
> + ? UTF_INVALID : udecoded;
>
> return len;
> }
> --
> 2.30.2
>
>

I'd like to keep these functions. drw.{c,h} and some util functions are shared
between some projects.

-- 
Kind regards,
Hiltjo
Received on Tue Aug 16 2022 - 00:00:52 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 16 2022 - 00:01:11 CEST