[PATCH 1/2] vi: use basic regular expressions for search

Christophe Leroy christophe.leroy at csgroup.eu
Mon Jun 28 12:39:00 UTC 2021



Le 28/06/2021 à 14:24, Andrey Dobrovolsky a écrit :
>  From b3b8fc90d095a4cfec5ad7448105ba3a815fb51e Mon Sep 17 00:00:00 2001
> From: Ron Yorston <rmy at pobox.com>
> Date: Fri, 25 Jun 2021 08:24:25 +0100
> Subject: [PATCH 1/2] vi: use basic regular expressions for search

Usually people send the patches to themself to tune their delivery scripts, not to the list.

> 
> Both traditional vi and vim use basic regular expressions for
> search.  Also, they don't allow matches to extend across line
> endings.  Thus with the file:
> 
>     123
>     234
> 
> the search '/2.*4$' should find the second '2', not the first.
> 
> Make BusyBox vi do the same.
> 
> Whether or not VI_REGEX_SEARCH is enabled:
> 
> function                                             old     new   delta
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0)                 Total: 0 bytes
> 
> Signed-off-by: Andrey Dobrovolsky <andrey.dobrovolsky.odessa at gmail.com>
> Signed-off-by: Ron Yorston <rmy at pobox.com>
> ---
>   editors/vi.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/editors/vi.c b/editors/vi.c
> index f0bbc9518..959362b25 100644
> --- a/editors/vi.c
> +++ b/editors/vi.c
> @@ -2378,9 +2378,9 @@ static char *char_search(char *p, const char *pat, int dir_and_range)
>   	char *q;
>   	int i, size, range, start;
>   
> -	re_syntax_options = RE_SYNTAX_POSIX_EXTENDED;
> +	re_syntax_options = RE_SYNTAX_POSIX_BASIC & (~RE_DOT_NEWLINE);
>   	if (ignorecase)
> -		re_syntax_options = RE_SYNTAX_POSIX_EXTENDED | RE_ICASE;
> +		re_syntax_options |= RE_ICASE;
>   
>   	memset(&preg, 0, sizeof(preg));
>   	err = re_compile_pattern(pat, strlen(pat), &preg);
> 
> 
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
> 


More information about the busybox mailing list