Re: grep: fix multibyte regex handling under macOS (1819ad327b7a1f19540a819813b70a0e8a7f798f)
- From
Jeff King <peff@peff.net>
- Date
- Feb 3, 2023, 16:55 UTC
- Message-ID
- <Y908f2qaxKeljtj+@coredump.intra.peff.net>
- In-Reply-To
- <CALnO6CA3LL2TbMyvVsgeNgGHr9tGq4-FYR0-RMyJJiMvV3P91w@mail.gmail.com>
On Thu, Feb 02, 2023 at 03:47:28PM -0500, D. Ben Knoble wrote:
Show 19 quoted lines
> Further, the following C program compiles without warnings (except for
> the unused main parameters):
> ```
> #include <regex.h>
> #include <assert.h>
> #include <stddef.h>
> #include <stdio.h>
>
> int main(int argc, char **argv) {
> regex_t re;
> int ret = regcomp(&re, "[\xc0-\xff][\x80-\xbf]+", REG_EXTENDED |
> REG_NEWLINE);
> /* assert(ret != 0); */
> size_t errbuf_size = regerror(ret, &re, NULL, 0);
> char errbuf[errbuf_size];
> regerror(ret, &re, errbuf, errbuf_size);
> printf("%s\n", errbuf);
> }
> ```Just a guess, but does calling:
setlocale(LC_CTYPE, "");
at the start of the program change things (you'll probably need to also include locale.h)? I don't have a macos system to test on.
-Peff