On Fri, May 12, 2023 at 11:11:23PM -0700, Jeremy Mates wrote:
> A search for /\/ is okay; this discards the \ and searches for "/"
>
> A search for ?\? is not okay; this discards the \ and searches for "?"
> which is an invalid regular expression, "RE error: repetition-operator
> operand invalid".
>
> A problematic bare leading ? on a backwards search can be escaped by
> the following, though I'm not sure if that's an ideal fix. Thoughts?
>
> --- search.c.orig Sat Dec 10 08:06:18 2022
> +++ search.c Fri May 12 23:05:31 2023
> @@ -120,6 +120,12 @@
> plen = t - ptrn;
> }
>
> + if (delim == '?' && *ptrn == '?') {
> + ptrn--;
> + plen++;
> + *ptrn = '\\';
> + }
> +
> /* Compile the RE. */
> if (re_compile(sp, ptrn, plen, &sp->re, &sp->re_len, &sp->re_c,
> RE_C_SEARCH |
I'm assuming this is with the "extended" option set in vi, right?
--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden
.