Tiny Core Linux

Tiny Core Base => TCB Talk => Topic started by: jazzbiker on November 24, 2018, 01:37:14 AM

Title: busybox vi command ":s/x/y/" searches not in the current line only
Post by: jazzbiker on November 24, 2018, 01:37:14 AM
Hi, staff!
Usually in vim command ":s/x/y/" applies only to current line. But in TC busybox vi this command continues search in next lines, until it finds pattern "x". It makes absolutely unusable substitutes with ranges, like "1,5s/x/y/", "/aaa/,/bbb/s/x/y/" and others. Is it bug or feature?
I loaded busybox sources 1.27.2 in case TC 9.0 and compiled them with "make defconfig". The resulting busybox vi command ":s"works as in traditional vim, but executable is twice greater, than "/bin/busybox".
Sorry, but I can't found which features are enabled in distribution busybox binary. Where can i find them?
The reason for me to use busybox vi is that I use TC 6.4.1 on one anscient laptop with 64M and have a nomadic flash drive with TC 9.0 for use everywhere.
Busybox vi is so tiny and usefull, I like it very much! As TinyCore too! It's wonderfull, OS of my dreams ) Thanks a lot!
Title: Re: busybox vi command ":s/x/y/" searches not in the current line only
Post by: Juanito on November 24, 2018, 01:49:11 AM
see http://tinycorelinux.net/8.x/x86_64/release/src/busybox/
Title: Re: busybox vi command ":s/x/y/" searches not in the current line only
Post by: Rich on November 24, 2018, 05:35:40 AM
Hi Juanito
I think you misread something in the question. Truth is I misread it too the first time. He probably wants the 32 bit version:
http://tinycorelinux.net/8.x/x86/release/src/busybox/
Title: Re: busybox vi command ":s/x/y/" searches not in the current line only
Post by: andyj on November 24, 2018, 05:37:35 AM
Busybox "s" command is broken. Try it in other distros, you'll get the same results. Use sed or vim instead.
Title: Re: busybox vi command ":s/x/y/" searches not in the current line only
Post by: jazzbiker on November 25, 2018, 12:02:33 PM
Thanks, guys, this is really busybox vi bug. It crawls out when busybox is compiled with FEATURE_VI_REGEX_SEARCH, as it is compiled in TinyCore.
Maybe not many people on this planet use busybox vi, seems only me ) ,because problem affected versions since 1.23 at least, and nobody was aware.
Patch for busybox 1.27.2 is tremendous:
Code: [Select]
1912a1913,1914
> if (range == LIMITED)
> q = next_line(p); // range is to next line
and must be applied to "editors/vi.c" in busybox source directory.
I don't know would it be useful for us? This variable check falled out of source long, long ago, and nobody cares (
I've sent this patch and 1.29.3 patch to busybox@busybox.net, maybe TC9.1 will make use of it )
Title: Re: busybox vi command ":s/x/y/" searches not in the current line only
Post by: jazzbiker on November 29, 2018, 08:22:08 AM
Denys Vlasenko made the commit to master branch of busybox, eliminating this bug. So substitution in vi will work correctly  for versions next to 1.29.3.
Title: Re: busybox vi command ":s/x/y/" searches not in the current line only
Post by: Juanito on November 29, 2018, 09:06:02 AM
Do you have a link to the commit?
Title: Re: busybox vi command ":s/x/y/" searches not in the current line only
Post by: jazzbiker on November 29, 2018, 10:23:34 AM
Commit, correcting regex search bug is https://git.busybox.net/busybox/commit/?id=836d0a7ee450893e7479b5f93a501454582955a2 and it became a part of consequent "code shrink" commit https://git.busybox.net/busybox/commit/?id=b7330460693f12585c7a6246f0dfafd8742af05a.