busybox/editors
Denys Vlasenko 95ac4a48f1 vi: allow regular expressions in ':s' commands
BusyBox vi has never supported the use of regular expressions in
search/replace (':s') commands.  Implement this using GNU regex
when VI_REGEX_SEARCH is enabled.

The implementation:

- uses basic regular expressions, to match those used in the search
  command;

- only supports substitution of back references ('\0' - '\9') in the
  replacement string.  Any other character following a backslash is
  treated as that literal character.

VI_REGEX_SEARCH isn't enabled in the default build.  In that case:

function                                             old     new   delta
colon                                               4036    4033      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3)               Total: -3 bytes

When VI_REGEX_SEARCH is enabled:

function                                             old     new   delta
colon                                               4036    4378    +342
.rodata                                           108207  108229     +22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 364/0)             Total: 364 bytes

v2: Rebase.  Code shrink.  Ensure empty replacement string is null terminated.

Signed-off-by: Andrey Dobrovolsky <andrey.dobrovolsky.odessa@gmail.com>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-13 14:38:20 +02:00
..
awk.c awk: in parsing, remove superfluous NEWLINE check; optimize builtin arg evaluation 2021-07-12 13:30:30 +02:00
cmp.c *: --help tweaks 2021-06-14 20:47:20 +02:00
Config.src restore documentation on the build config language 2018-06-06 15:16:48 +02:00
diff.c diff: code shrink 2021-02-22 19:00:07 +01:00
ed.c libbb: introduce and use fputs_stdout 2021-02-03 20:52:40 +01:00
Kbuild.src switch editors/* to embedded-in-source kbuild system 2013-11-13 12:45:33 +01:00
patch_bbox.c libbb: reduce the overhead of single parameter bb_error_msg() calls 2019-07-02 11:35:03 +02:00
patch_toybox.c libbb: reduce the overhead of single parameter bb_error_msg() calls 2019-07-02 11:35:03 +02:00
patch.c help text: replace [OPTIONS] with actual options (if not too long) 2020-12-13 22:34:05 +01:00
sed_summary.htm doc: add info about sed s/.../.../I modifier 2008-03-01 19:29:56 +00:00
sed.c *: --help tweaks 2021-06-13 01:08:48 +02:00
sed1line.txt add sed mini-doc 2007-11-13 17:13:31 +00:00
vi.c vi: allow regular expressions in ':s' commands 2021-07-13 14:38:20 +02:00