Undo for "vi"

Jody Bruchon jody at jodybruchon.com
Tue Mar 18 14:51:48 UTC 2014


On 3/18/2014 9:24 AM, Laszlo Papp wrote:
> Hi,
>
> do you plan to implement this feature any soon? It would be really
> useful. Currently, it is a bit difficult to do undo in certain
> scenarios when editing files on the embedded board.

Out of an interest in seeing this feature, I'm looking at vi.c and find 
that the code is not terribly well commented. For example, variables 'p' 
and 'q' are used throughout the code but no explanation of what they are 
supposed to be for or what is happening with them exists.

Could someone who has worked on this code give me an idea of what this 
block of code really does?

-snip-

#if ENABLE_FEATURE_VI_COLON
     {
         char *p, *q;
         int n = 0;

         while ((p = initial_cmds[n]) != NULL) {
             do {
                 q = p;
                 p = strchr(q, '\n');
                 if (p)
                     while (*p == '\n')
                         *p++ = '\0';
                 if (*q)
                     colon(q);
             } while (p);
             free(initial_cmds[n]);
             initial_cmds[n] = NULL;
             n++;
         }
     }
#endif

-snip-


Thanks in advance!
-Jody Bruchon


More information about the busybox mailing list