t-ctype: allow NUL anywhere in the specification string
commit980013e90dd12ec1ff9eec23cebb0c845f198dab
authorRené Scharfe <l.s.r@web.de>
Sun, 3 Mar 2024 10:13:25 +0000 (3 11:13 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 3 Mar 2024 17:47:33 +0000 (3 09:47 -0800)
tree16af3d2c2850d474b9185b66e52806d5cbfe947c
parent3c2a3fdc388747b9eaf4a4a4f2035c1c9ddb26d0
t-ctype: allow NUL anywhere in the specification string

Replace the custom function is_in() for looking up a character in the
specification string with memchr(3) and sizeof.  This is shorter,
simpler and allows NUL anywhere in the string, which may come in handy
if we ever want to support more character classes that contain it.

Getting the string size using sizeof only works in a macro and with a
string constant.  Use ARRAY_SIZE and compile-time checks to make sure we
are not passed a string pointer.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/unit-tests/t-ctype.c