[Toybox] vi

Rob Landley rob at landley.net
Thu Jun 17 02:05:40 PDT 2021

On 6/16/21 1:32 PM, Frank Liu wrote:
> Hi,
> I am not sure how far we are on the vi in toybox. Just enabled it in the build
> and tried:
> "vi" alone gives:
> Floating point exception (core dumped)

There's a reason it's in pending. Ok, fixed up the mmap(0), and...

    sprintf(toybuf, "%zu/%zuC  %zu%%  %d,%d", TT.cursor, TT.filesize,
      (100*TT.cursor)/TT.filesize, TT.cur_row+1, TT.cur_col+1);

Yup, that's a division by zero error. Ok, fix that up and...

Wow, it's still behaving terribly. Doesn't look like it can cope with the data
structure being actually empty.

You can i and type lines and they vanish when you hit enter. The function looks
like it returns 1 when run with no filename (as in vi with no arguments) but
none of the callers ever CHECK its return value. Still, it behaves...
DIFFERENTLY when you do that? (Something elsewhere must be checking for an empty
filename, which is the wrong test.) It will then remember ONE line, but when you
type  a second your cursor is down in tilde space (advancing to the right, but
nothing shows up). And then :w enter to save dies with an error message about
renaming (null).swp and... yes, it created a file "(null).swp" which has just
the first line I typed but none of the later ones.

Needs work.

> touch newfile; vi newfile
> vi: mmap: Invalid argument
> vi existing_non_empty_file
> seems to work

I would not trust this command to hold weight. It's in pending for a reason. I
need a large chunk of time to devote to it at some point, but I need to empty
out a few of the open cans of worms first...

> I normally use Space key to navigate to the right but that doesn't seem to work,
> I have to use l key or right arrow key.
> :1  doesn't bring me to line 1 (:number doesn't seem to work).

I didn't write this one and haven't looked at it much. You could ask Jarno.


More information about the Toybox mailing list