Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

vi line range bugfix



-----BEGIN PGP SIGNED MESSAGE-----

This patch fixes the handling of vi line ranges.  It makes sure the
vilinerange flag gets cleared appropriatly; previously a non-line cut
could be treated as a line-range cut because the flag was set by an
earlier operation.  It also fixes appending of line ranges to non-line
buffers and vice versa.

 -zefram

      *** Src/Zle/zle_main.c	1997/03/29 23:36:06	1.35
      --- Src/Zle/zle_main.c	1997/05/03 14:44:20
      ***************
      *** 382,388 ****
        #endif
        	undoing = 1;
        	line = (unsigned char *)zalloc((linesz = 256) + 2);
      ! 	virangeflag = vilinerange = lastcmd = done = cs = ll = mark = 0;
        	curhistline = NULL;
        	addedsuffix = complexpect = vichgflag = 0;
        	viinsbegin = 0;
      --- 382,388 ----
        #endif
        	undoing = 1;
        	line = (unsigned char *)zalloc((linesz = 256) + 2);
      ! 	virangeflag = lastcmd = done = cs = ll = mark = 0;
        	curhistline = NULL;
        	addedsuffix = complexpect = vichgflag = 0;
        	viinsbegin = 0;
      ***************
      *** 418,423 ****
      --- 418,424 ----
        	while (!done && !errflag) {
        
        	    statusline = NULL;
      + 	    vilinerange = 0;
        	    reselectkeymap();
        	    bindk = getkeycmd();
        	    if (!ll && isfirstln && c == eofchar) {
      *** Src/Zle/zle_utils.c	1997/03/23 20:20:49	1.14
      --- Src/Zle/zle_utils.c	1997/05/03 14:34:16
      ***************
      *** 104,129 ****
            if (zmod.flags & MOD_VIBUF) {
        	struct cutbuffer *b = &vibuf[zmod.vibuf];
        
      ! 	if (!(zmod.flags & MOD_VIAPP) || !b->buf ||
      ! 	    ((b->flags & CUTBUFFER_LINE) && !vilinerange)) {
        	    zfree(b->buf, b->len);
        	    b->buf = (char *)zalloc(ct);
        	    memcpy(b->buf, (char *) line + i, ct);
        	    b->len = ct;
      ! 	    b->flags = 0;
        	} else {
        	    int len = b->len;
        
      ! 	    b->buf = realloc(b->buf, ct + len + 1);
      ! 	    if (vilinerange)
        		b->buf[len++] = '\n';
        	    memcpy(b->buf + len, (char *) line + i, ct);
        	    b->len = len + ct;
        	}
      - 	if(vilinerange)
      - 	    b->flags |= CUTBUFFER_LINE;
      - 	else
      - 	    b->flags &= ~CUTBUFFER_LINE;
        	return;
            } else {
        	/* Save in "1, shifting "1-"8 along to "2-"9 */
      --- 104,126 ----
            if (zmod.flags & MOD_VIBUF) {
        	struct cutbuffer *b = &vibuf[zmod.vibuf];
        
      ! 	if (!(zmod.flags & MOD_VIAPP) || !b->buf) {
        	    zfree(b->buf, b->len);
        	    b->buf = (char *)zalloc(ct);
        	    memcpy(b->buf, (char *) line + i, ct);
        	    b->len = ct;
      ! 	    b->flags = vilinerange ? CUTBUFFER_LINE : 0;
        	} else {
        	    int len = b->len;
        
      ! 	    if(vilinerange)
      ! 		b->flags |= CUTBUFFER_LINE;
      ! 	    b->buf = realloc(b->buf, ct + len + !!(b->flags & CUTBUFFER_LINE));
      ! 	    if (b->flags & CUTBUFFER_LINE)
        		b->buf[len++] = '\n';
        	    memcpy(b->buf + len, (char *) line + i, ct);
        	    b->len = len + ct;
        	}
        	return;
            } else {
        	/* Save in "1, shifting "1-"8 along to "2-"9 */
      *** Src/Zle/zle_vi.c	1997/03/23 20:20:50	1.10
      --- Src/Zle/zle_vi.c	1997/05/03 14:46:15
      ***************
      *** 205,211 ****
        	cs = pos;
        	pos = findeol();
        	cs = newcs;
      - 	vilinerange = 1;
            }
            return pos;
        }
      --- 205,210 ----
      ***************
      *** 295,301 ****
        	    vifirstnonblank();
        	}
            }
      !     vichgflag = vilinerange = 0;
        }
        
        /**/
      --- 294,300 ----
        	    vifirstnonblank();
        	}
            }
      !     vichgflag = 0;
        }
        
        /**/
      ***************
      *** 338,344 ****
        	viinsbegin = cs;
        	undoing = 0;
            }
      -     vilinerange = 0;
        }
        
        /**/
      --- 337,342 ----
      ***************
      *** 391,397 ****
            startvichange(1);
            if ((c2 = getvirange(0)) != -1)
        	cut(cs, c2 - cs, 0);
      !     vichgflag = vilinerange = 0;
            cs = oldcs;
        }
        
      --- 389,395 ----
            startvichange(1);
            if ((c2 = getvirange(0)) != -1)
        	cut(cs, c2 - cs, 0);
      !     vichgflag = 0;
            cs = oldcs;
        }
        
      ***************
      *** 548,554 ****
        	cs = oldcs;
        	vifirstnonblank();
            }
      !     vichgflag = vilinerange = 0;
        }
        
        /**/
      --- 546,552 ----
        	cs = oldcs;
        	vifirstnonblank();
            }
      !     vichgflag = 0;
        }
        
        /**/
      ***************
      *** 584,590 ****
            /* get the range */
            startvichange(1);
            if ((c2 = getvirange(0)) == -1) {
      ! 	vichgflag = vilinerange = 0;
        	return;
            }
            vichgflag = 0;
      --- 582,588 ----
            /* get the range */
            startvichange(1);
            if ((c2 = getvirange(0)) == -1) {
      ! 	vichgflag = 0;
        	return;
            }
            vichgflag = 0;
      ***************
      *** 594,600 ****
        	cs = oldcs;
        	return;
            }
      -     vilinerange = 0;
            oldcs = cs;
            /* add a tab to the beginning of each line within range */
            while (cs < c2) {
      --- 592,597 ----
      ***************
      *** 616,622 ****
            /* get the range */
            startvichange(1);
            if ((c2 = getvirange(0)) == -1) {
      ! 	vichgflag = vilinerange = 0;
        	return;
            }
            vichgflag = 0;
      --- 613,619 ----
            /* get the range */
            startvichange(1);
            if ((c2 = getvirange(0)) == -1) {
      ! 	vichgflag = 0;
        	return;
            }
            vichgflag = 0;
      ***************
      *** 626,632 ****
        	cs = oldcs;
        	return;
            }
      -     vilinerange = 0;
            oldcs = cs;
            /* remove a tab from the beginning of each line within range */
            while (cs < c2) {
      --- 623,628 ----
      ***************
      *** 695,702 ****
        	feep();
        	return;
            }
      !     vilinerange = !!(buf->flags & CUTBUFFER_LINE);
      !     if (vilinerange) {
        	cs = findbol();
        	spaceinline(buf->len + 1);
        	memcpy((char *)line + cs, buf->buf, buf->len);
      --- 691,697 ----
        	feep();
        	return;
            }
      !     if(buf->flags & CUTBUFFER_LINE) {
        	cs = findbol();
        	spaceinline(buf->len + 1);
        	memcpy((char *)line + cs, buf->buf, buf->len);
      ***************
      *** 729,736 ****
        	feep();
        	return;
            }
      !     vilinerange = !!(buf->flags & CUTBUFFER_LINE);
      !     if (vilinerange) {
        	cs = findeol();
        	spaceinline(buf->len + 1);
        	line[cs++] = '\n';
      --- 724,730 ----
        	feep();
        	return;
            }
      !     if(buf->flags & CUTBUFFER_LINE) {
        	cs = findeol();
        	spaceinline(buf->len + 1);
        	line[cs++] = '\n';

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: ascii

iQCVAwUBM2tRsnD/+HJTpU/hAQGobQP/Sxk9utBxth3YcHytwX6fCSrAnLi15AQp
kPHKPST0a8OZrX5xhPTBhh8EjBB+PcuPSZicImgQYPsAVO/1DzooSW9bPBo02HhR
BnWUsZoIXEZEZdYeAXRDwlPzGz8YmsqEW2C9ePd/j8kyq8KF+/0siSCf0Euh+Z2a
p/0qpnrlal4=
=7MxH
-----END PGP SIGNATURE-----



Messages sorted by: Reverse Date, Date, Thread, Author