From: Junio C Hamano Date: Wed, 21 Sep 2016 19:17:56 GMT Subject: Re: [PATCH v4 2/3] regex: add regexec_buf() that can work on a non NUL-terminated string Message-ID: In-Reply-To: <270cea11c4d8bfb332a6c014a11673b7f4666ee4.1474482164.git.johannes.schindelin@gmx.de> Johannes Schindelin writes: > ... > Happily, there is an extension to regexec() introduced by the NetBSD > project and present in all major regex implementation including > Linux', MacOSX' and the one Git includes in compat/regex/: by using > the (non-POSIX) REG_STARTEND flag, it is possible to tell the > regexec() function that it should only look at the offsets between > pmatch[0].rm_so and pmatch[0].rm_eo. > > That is exactly what we need. Wonderful. > Since support for REG_STARTEND is so widespread by now, let's just > introduce a helper function that uses it, and fall back to allocating > and constructing a NUL-terminated when REG_STARTEND is not available. I'd somehow reword the last paragraph here, though ;-) Since support for REG_STARTEND is so widespread by now, let's just introduce a helper function that always uses it, and tell people on a platform whose regex library does not support it to use the one from our compat/regex/ directory. The patch itself looks very sane. Thanks.