[Toybox] [PATCH] vi.c: added v command, updated help text, Fixed memory leak in 'g' command

Oliver Webb aquahobbyist at proton.me
Tue Oct 17 16:41:57 PDT 2023


------- Original Message -------
On Tuesday, October 17th, 2023 at 04:42, Rob Landley <rob at landley.net> wrote:


> On 10/16/23 22:29, Oliver Webb wrote:
> 
> > > I was hoping to get stuff to share code, but I can worry about that in the
> > > eventual cleanup pass.
> > 
> > If you are planning on code-sharing the regex line substitution stuff.
> > Then this will probably be my last patch to vi.c for a while
> > (Unless there is something wrong with it that can be fixed reasonably).
> 
> 
> "Planning" is a strong word. I would generally like code to be shared in the
> toybox when that isn't hard to do, but I haven't evaluated how hard it is to do
> here.

When attempting to write 's'[ubsitute] in vi. I tried to copy off sed.c more then once.
Although the reason I failed probably because I am unfamiliar with the code for sed.

> Elsewhere, I'm 3/4 of the way to convincing myself to just add hd/hexdump as a
> fourth implementation of the same darn thing, because hexedit, xxd, and od
> aren't really set up to share code with each other and neither of them is an
> obvious base for hd either. The perfect is the enemy of the good and all that...
> 
> > I have removed some of the overhead to minimize throughput, Replacing "run_vi_cmd("j")"
> > with "cur_down(1, 1, 0)" The page clearing function calls with setting vi_mov_flag, etc.
> 
> 
> The person who ISN'T currently doing work shouldn't stand in the way of somebody
> who's got momentum. You've built some familiarity with the vi codebase and seem
> to be doing good things with it, I have no intention of stopping you, and I've
> applied your patch.

My main goal for vi.c was to put some ex commands I commonly used into it. 
The only non-trivial thing I had left to implement was the 's' command.
And once that is implemented, I don't really have many other things I would care to implement in vi.
If the regex line substitution algorithm gets code-shared OR it's not viable to code-share 
it in the cleanup pass I'll probably resume work on vi.c to add a 's' command if it's not already there.

The reason I started poking at other commands like count is because, now that the ex commands in vi have
90% of the things I care about. Perfecting them (Adding special formatting like "2,+5" into line ranges, 
Non-global global commands, Prying the ex commands from 'run_vi_cmd()' to minimize throughput, etc)
doesn't matter to me as much as adding to/fixing other stuff in toybox.

That being said, and after looking closer at vi.c. There are a few things other then ex commands
That I could add. I added backwards searches, with the corresponding 
"N" (goto previous match while searching) (vi normal mode, not ex) command.
The 'j'[oin] ex command is occasionally useful in conjunction with 'g' so I added that too.

- Oliver Webb <aquahobbyist at proton.me>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-vi.c-add-backwards-search-add-j-oin-ex-command.patch
Type: text/x-patch
Size: 3665 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20231017/89fd67e6/attachment.bin>


More information about the Toybox mailing list