2007-01-12 17:45:13 +01:00
|
|
|
--- src/cmd/ksh93/edit/vi.c
|
2016-10-12 13:36:28 +02:00
|
|
|
+++ src/cmd/ksh93/edit/vi.c 2007-03-28 16:41:47.000000000 +0000
|
|
|
|
@@ -401,6 +401,8 @@ int ed_viread(void *context, int fd, reg
|
2007-04-03 21:36:49 +02:00
|
|
|
|
2007-01-12 17:45:13 +01:00
|
|
|
if(!yankbuf)
|
|
|
|
yankbuf = (genchar*)malloc(MAXLINE*CHARSIZE);
|
|
|
|
+ if (!vp->lastline)
|
2007-04-03 21:36:49 +02:00
|
|
|
+ vp->lastline = (genchar*)malloc(MAXLINE*CHARSIZE);
|
2007-01-12 17:45:13 +01:00
|
|
|
if( vp->last_cmd == '\0' )
|
2007-04-03 21:36:49 +02:00
|
|
|
{
|
|
|
|
/*** first time for this shell ***/
|
2016-10-12 13:36:28 +02:00
|
|
|
@@ -410,6 +412,8 @@ int ed_viread(void *context, int fd, reg
|
2007-01-12 17:45:13 +01:00
|
|
|
vp->lastmotion = '\0';
|
|
|
|
vp->lastrepeat = 1;
|
|
|
|
vp->repeat = 1;
|
|
|
|
+ if (!yankbuf)
|
|
|
|
+ return(-1);
|
|
|
|
*yankbuf = 0;
|
|
|
|
}
|
|
|
|
|
2016-10-12 13:36:28 +02:00
|
|
|
@@ -1137,7 +1141,7 @@ static void cdelete(Vi_t *vp,register in
|
2007-01-12 17:45:13 +01:00
|
|
|
|
|
|
|
/*** save characters to be deleted ***/
|
|
|
|
|
|
|
|
- if( mode != 'c' )
|
|
|
|
+ if( mode != 'c' && yankbuf )
|
|
|
|
{
|
|
|
|
i = cp[nchars];
|
|
|
|
cp[nchars] = 0;
|
2016-10-12 13:36:28 +02:00
|
|
|
@@ -2169,6 +2173,9 @@ static void save_last(register Vi_t* vp)
|
2007-01-12 17:45:13 +01:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
+ if (vp->lastline == NULL)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
if( (i = cur_virt - first_virt + 1) > 0 )
|
|
|
|
{
|
|
|
|
/*** save last thing user typed ***/
|
2016-10-12 13:36:28 +02:00
|
|
|
@@ -2417,6 +2424,11 @@ static int textmod(register Vi_t *vp,reg
|
2007-01-12 17:45:13 +01:00
|
|
|
p = yankbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (!p)
|
|
|
|
+ {
|
|
|
|
+ return(BAD);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
addin:
|
|
|
|
switch( c )
|
|
|
|
{
|
2016-10-12 13:36:28 +02:00
|
|
|
@@ -2687,6 +2699,8 @@ yankeol:
|
2007-01-12 17:45:13 +01:00
|
|
|
vp->lastmotion = c;
|
|
|
|
if( c == 'y' )
|
|
|
|
{
|
|
|
|
+ if (!yankbuf)
|
|
|
|
+ return(BAD);
|
|
|
|
gencpy(yankbuf, virtual);
|
|
|
|
}
|
|
|
|
else if(!delmotion(vp, c, 'y'))
|