old vi bug still alive ...

Denys Vlasenko vda.linux at googlemail.com
Fri Nov 21 10:53:25 UTC 2008


On Thu, Nov 20, 2008 at 5:39 PM, walter harms <wharms at bfs.de> wrote:
> hi Denys,
>
> the patch seems to work, i was unable to replicate the bug.
> i had the feeling that vi is solower now, but i may be wrong
> since i crashed early most times.

Yes. For example, again, when you press <Enter>
autoindent will do:

                        for (; isblank(*q); q++) {
                                uintptr_t bias = stupid_insert(p, *q);
 // insert the char
                                p += bias + 1;
                                q += bias;
                        }

Thus we do stupid_insert for every whitespace char
in the preceding line (imagine ~50 space chars),
and stupid_insert -> text_hole_make will do:

        memmove(p + size, p, end - size - p);
        memset(p, ' ', size);   // clear new hole

50 memmove's, each moving around entire tail of the file!
You might want to make a patch which does:

1. measure how many blank chars are there.
2. tmp = xstrndup(q, num_blank_ch);
3. string_insert(p, tmp);
4. free(tmp);

instead of that for() loop.
--
vda



More information about the busybox mailing list