[libc] Harden regerror null check and use string_view (#242402)
POSIX permits calling regerror with a null buffer when errbuf_size is 0
to query the required buffer length, but passing a null buffer with a
non-zero errbuf_size is undefined behaviour. Previously, regerror
silently skipped writing when errbuf was null and errbuf_size was
non-zero, diverging from the null-pointer hardening in regcomp, regexec,
and regfree.
Guard errbuf with LIBC_CRASH_ON_NULLPTR when errbuf_size > 0 while
preserving size queries when errbuf_size == 0. Return cpp::string_view
directly from the message lookup lambda so literal lengths fold at
compile time without a runtime strlen scan.
Assisted-by: Automated tooling, human reviewed.