Karsten Hopp 6c1ae6
To: vim-dev@vim.org
Karsten Hopp 6c1ae6
Subject: Patch 7.0.044
Karsten Hopp 6c1ae6
Fcc: outbox
Karsten Hopp 6c1ae6
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 6c1ae6
Mime-Version: 1.0
Karsten Hopp 6c1ae6
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 6c1ae6
Content-Transfer-Encoding: 8bit
Karsten Hopp 6c1ae6
------------
Karsten Hopp 6c1ae6
Karsten Hopp 6c1ae6
Patch 7.0.044
Karsten Hopp 6c1ae6
Problem:    Perl: setting a buffer line in another buffer may result in
Karsten Hopp 6c1ae6
	    changing the current buffer.
Karsten Hopp 6c1ae6
Solution:   Properly change to the buffer to be changed.
Karsten Hopp 6c1ae6
Files:	    src/if_perl.xs
Karsten Hopp 6c1ae6
Karsten Hopp 6c1ae6
Karsten Hopp 6c1ae6
*** ../vim-7.0.043/src/if_perl.xs	Tue Mar  7 00:18:16 2006
Karsten Hopp 6c1ae6
--- src/if_perl.xs	Thu Jun 22 21:22:18 2006
Karsten Hopp 6c1ae6
***************
Karsten Hopp 6c1ae6
*** 1056,1062 ****
Karsten Hopp 6c1ae6
      int i;
Karsten Hopp 6c1ae6
      long lnum;
Karsten Hopp 6c1ae6
      char *line;
Karsten Hopp 6c1ae6
-     buf_T *savebuf;
Karsten Hopp 6c1ae6
      PPCODE:
Karsten Hopp 6c1ae6
      if (buf_valid(vimbuf))
Karsten Hopp 6c1ae6
      {
Karsten Hopp 6c1ae6
--- 1056,1061 ----
Karsten Hopp 6c1ae6
***************
Karsten Hopp 6c1ae6
*** 1069,1082 ****
Karsten Hopp 6c1ae6
  	    line = SvPV(ST(i),PL_na);
Karsten Hopp 6c1ae6
  	    if (lnum > 0 && lnum <= vimbuf->b_ml.ml_line_count && line != NULL)
Karsten Hopp 6c1ae6
  	    {
Karsten Hopp 6c1ae6
! 		savebuf = curbuf;
Karsten Hopp 6c1ae6
  		curbuf = vimbuf;
Karsten Hopp 6c1ae6
  		if (u_savesub(lnum) == OK)
Karsten Hopp 6c1ae6
  		{
Karsten Hopp 6c1ae6
  		    ml_replace(lnum, (char_u *)line, TRUE);
Karsten Hopp 6c1ae6
  		    changed_bytes(lnum, 0);
Karsten Hopp 6c1ae6
  		}
Karsten Hopp 6c1ae6
! 		curbuf = savebuf;
Karsten Hopp 6c1ae6
  	    }
Karsten Hopp 6c1ae6
  	}
Karsten Hopp 6c1ae6
      }
Karsten Hopp 6c1ae6
--- 1068,1098 ----
Karsten Hopp 6c1ae6
  	    line = SvPV(ST(i),PL_na);
Karsten Hopp 6c1ae6
  	    if (lnum > 0 && lnum <= vimbuf->b_ml.ml_line_count && line != NULL)
Karsten Hopp 6c1ae6
  	    {
Karsten Hopp 6c1ae6
!     #ifdef FEAT_AUTOCMD
Karsten Hopp 6c1ae6
! 		aco_save_T	aco;
Karsten Hopp 6c1ae6
! 
Karsten Hopp 6c1ae6
! 		/* set curwin/curbuf for "vimbuf" and save some things */
Karsten Hopp 6c1ae6
! 		aucmd_prepbuf(&aco, vimbuf);
Karsten Hopp 6c1ae6
!     #else
Karsten Hopp 6c1ae6
! 		buf_T	*save_curbuf = curbuf;
Karsten Hopp 6c1ae6
! 
Karsten Hopp 6c1ae6
  		curbuf = vimbuf;
Karsten Hopp 6c1ae6
+ 		curwin->w_buffer = vimbuf;
Karsten Hopp 6c1ae6
+     #endif
Karsten Hopp 6c1ae6
  		if (u_savesub(lnum) == OK)
Karsten Hopp 6c1ae6
  		{
Karsten Hopp 6c1ae6
  		    ml_replace(lnum, (char_u *)line, TRUE);
Karsten Hopp 6c1ae6
  		    changed_bytes(lnum, 0);
Karsten Hopp 6c1ae6
  		}
Karsten Hopp 6c1ae6
! 
Karsten Hopp 6c1ae6
!     #ifdef FEAT_AUTOCMD
Karsten Hopp 6c1ae6
! 		/* restore curwin/curbuf and a few other things */
Karsten Hopp 6c1ae6
! 		aucmd_restbuf(&aco;;
Karsten Hopp 6c1ae6
! 		/* Careful: autocommands may have made "vimbuf" invalid! */
Karsten Hopp 6c1ae6
!     #else
Karsten Hopp 6c1ae6
! 		curwin->w_buffer = save_curbuf;
Karsten Hopp 6c1ae6
! 		curbuf = save_curbuf;
Karsten Hopp 6c1ae6
!     #endif
Karsten Hopp 6c1ae6
  	    }
Karsten Hopp 6c1ae6
  	}
Karsten Hopp 6c1ae6
      }
Karsten Hopp 6c1ae6
***************
Karsten Hopp 6c1ae6
*** 1087,1093 ****
Karsten Hopp 6c1ae6
  
Karsten Hopp 6c1ae6
      PREINIT:
Karsten Hopp 6c1ae6
      long i, lnum = 0, count = 0;
Karsten Hopp 6c1ae6
-     buf_T *savebuf;
Karsten Hopp 6c1ae6
      PPCODE:
Karsten Hopp 6c1ae6
      if (buf_valid(vimbuf))
Karsten Hopp 6c1ae6
      {
Karsten Hopp 6c1ae6
--- 1103,1108 ----
Karsten Hopp 6c1ae6
***************
Karsten Hopp 6c1ae6
*** 1114,1129 ****
Karsten Hopp 6c1ae6
  	    {
Karsten Hopp 6c1ae6
  		if (lnum > 0 && lnum <= vimbuf->b_ml.ml_line_count)
Karsten Hopp 6c1ae6
  		{
Karsten Hopp 6c1ae6
! 		    savebuf = curbuf;
Karsten Hopp 6c1ae6
  		    curbuf = vimbuf;
Karsten Hopp 6c1ae6
  		    if (u_savedel(lnum, 1) == OK)
Karsten Hopp 6c1ae6
  		    {
Karsten Hopp 6c1ae6
  			ml_delete(lnum, 0);
Karsten Hopp 6c1ae6
  			deleted_lines_mark(lnum, 1L);
Karsten Hopp 6c1ae6
! 			if (savebuf == curbuf)
Karsten Hopp 6c1ae6
  			    check_cursor();
Karsten Hopp 6c1ae6
  		    }
Karsten Hopp 6c1ae6
! 		    curbuf = savebuf;
Karsten Hopp 6c1ae6
  		    update_curbuf(VALID);
Karsten Hopp 6c1ae6
  		}
Karsten Hopp 6c1ae6
  	    }
Karsten Hopp 6c1ae6
--- 1129,1159 ----
Karsten Hopp 6c1ae6
  	    {
Karsten Hopp 6c1ae6
  		if (lnum > 0 && lnum <= vimbuf->b_ml.ml_line_count)
Karsten Hopp 6c1ae6
  		{
Karsten Hopp 6c1ae6
! 		    buf_T	*save_curbuf = curbuf;
Karsten Hopp 6c1ae6
!     #ifdef FEAT_AUTOCMD
Karsten Hopp 6c1ae6
! 		    aco_save_T	aco;
Karsten Hopp 6c1ae6
! 
Karsten Hopp 6c1ae6
! 		    /* set curwin/curbuf for "vimbuf" and save some things */
Karsten Hopp 6c1ae6
! 		    aucmd_prepbuf(&aco, vimbuf);
Karsten Hopp 6c1ae6
!     #else
Karsten Hopp 6c1ae6
  		    curbuf = vimbuf;
Karsten Hopp 6c1ae6
+ 		    curwin->w_buffer = vimbuf;
Karsten Hopp 6c1ae6
+     #endif
Karsten Hopp 6c1ae6
  		    if (u_savedel(lnum, 1) == OK)
Karsten Hopp 6c1ae6
  		    {
Karsten Hopp 6c1ae6
  			ml_delete(lnum, 0);
Karsten Hopp 6c1ae6
  			deleted_lines_mark(lnum, 1L);
Karsten Hopp 6c1ae6
! 			if (save_curbuf == curbuf)
Karsten Hopp 6c1ae6
  			    check_cursor();
Karsten Hopp 6c1ae6
  		    }
Karsten Hopp 6c1ae6
!     #ifdef FEAT_AUTOCMD
Karsten Hopp 6c1ae6
! 		    /* restore curwin/curbuf and a few other things */
Karsten Hopp 6c1ae6
! 		    aucmd_restbuf(&aco;;
Karsten Hopp 6c1ae6
! 		    /* Careful: autocommands may have made "vimbuf" invalid! */
Karsten Hopp 6c1ae6
!     #else
Karsten Hopp 6c1ae6
! 		    curwin->w_buffer = save_curbuf;
Karsten Hopp 6c1ae6
! 		    curbuf = save_curbuf;
Karsten Hopp 6c1ae6
!     #endif
Karsten Hopp 6c1ae6
  		    update_curbuf(VALID);
Karsten Hopp 6c1ae6
  		}
Karsten Hopp 6c1ae6
  	    }
Karsten Hopp 6c1ae6
***************
Karsten Hopp 6c1ae6
*** 1138,1144 ****
Karsten Hopp 6c1ae6
      int		i;
Karsten Hopp 6c1ae6
      long	lnum;
Karsten Hopp 6c1ae6
      char	*line;
Karsten Hopp 6c1ae6
-     buf_T	*savebuf;
Karsten Hopp 6c1ae6
      PPCODE:
Karsten Hopp 6c1ae6
      if (buf_valid(vimbuf))
Karsten Hopp 6c1ae6
      {
Karsten Hopp 6c1ae6
--- 1168,1173 ----
Karsten Hopp 6c1ae6
***************
Karsten Hopp 6c1ae6
*** 1151,1164 ****
Karsten Hopp 6c1ae6
  	    line = SvPV(ST(i),PL_na);
Karsten Hopp 6c1ae6
  	    if (lnum >= 0 && lnum <= vimbuf->b_ml.ml_line_count && line != NULL)
Karsten Hopp 6c1ae6
  	    {
Karsten Hopp 6c1ae6
! 		savebuf = curbuf;
Karsten Hopp 6c1ae6
  		curbuf = vimbuf;
Karsten Hopp 6c1ae6
  		if (u_inssub(lnum + 1) == OK)
Karsten Hopp 6c1ae6
  		{
Karsten Hopp 6c1ae6
  		    ml_append(lnum, (char_u *)line, (colnr_T)0, FALSE);
Karsten Hopp 6c1ae6
  		    appended_lines_mark(lnum, 1L);
Karsten Hopp 6c1ae6
  		}
Karsten Hopp 6c1ae6
! 		curbuf = savebuf;
Karsten Hopp 6c1ae6
  		update_curbuf(VALID);
Karsten Hopp 6c1ae6
  	    }
Karsten Hopp 6c1ae6
  	}
Karsten Hopp 6c1ae6
--- 1180,1210 ----
Karsten Hopp 6c1ae6
  	    line = SvPV(ST(i),PL_na);
Karsten Hopp 6c1ae6
  	    if (lnum >= 0 && lnum <= vimbuf->b_ml.ml_line_count && line != NULL)
Karsten Hopp 6c1ae6
  	    {
Karsten Hopp 6c1ae6
!     #ifdef FEAT_AUTOCMD
Karsten Hopp 6c1ae6
! 		aco_save_T	aco;
Karsten Hopp 6c1ae6
! 
Karsten Hopp 6c1ae6
! 		/* set curwin/curbuf for "vimbuf" and save some things */
Karsten Hopp 6c1ae6
! 		aucmd_prepbuf(&aco, vimbuf);
Karsten Hopp 6c1ae6
!     #else
Karsten Hopp 6c1ae6
! 		buf_T	*save_curbuf = curbuf;
Karsten Hopp 6c1ae6
! 
Karsten Hopp 6c1ae6
  		curbuf = vimbuf;
Karsten Hopp 6c1ae6
+ 		curwin->w_buffer = vimbuf;
Karsten Hopp 6c1ae6
+     #endif
Karsten Hopp 6c1ae6
  		if (u_inssub(lnum + 1) == OK)
Karsten Hopp 6c1ae6
  		{
Karsten Hopp 6c1ae6
  		    ml_append(lnum, (char_u *)line, (colnr_T)0, FALSE);
Karsten Hopp 6c1ae6
  		    appended_lines_mark(lnum, 1L);
Karsten Hopp 6c1ae6
  		}
Karsten Hopp 6c1ae6
! 
Karsten Hopp 6c1ae6
!     #ifdef FEAT_AUTOCMD
Karsten Hopp 6c1ae6
! 		/* restore curwin/curbuf and a few other things */
Karsten Hopp 6c1ae6
! 		aucmd_restbuf(&aco;;
Karsten Hopp 6c1ae6
! 		/* Careful: autocommands may have made "vimbuf" invalid! */
Karsten Hopp 6c1ae6
!     #else
Karsten Hopp 6c1ae6
! 		curwin->w_buffer = save_curbuf;
Karsten Hopp 6c1ae6
! 		curbuf = save_curbuf;
Karsten Hopp 6c1ae6
!     #endif
Karsten Hopp 6c1ae6
  		update_curbuf(VALID);
Karsten Hopp 6c1ae6
  	    }
Karsten Hopp 6c1ae6
  	}
Karsten Hopp 6c1ae6
*** ../vim-7.0.043/src/version.c	Tue Aug  8 16:30:51 2006
Karsten Hopp 6c1ae6
--- src/version.c	Tue Aug  8 16:45:40 2006
Karsten Hopp 6c1ae6
***************
Karsten Hopp 6c1ae6
*** 668,669 ****
Karsten Hopp 6c1ae6
--- 668,671 ----
Karsten Hopp 6c1ae6
  {   /* Add new patch number below this line */
Karsten Hopp 6c1ae6
+ /**/
Karsten Hopp 6c1ae6
+     44,
Karsten Hopp 6c1ae6
  /**/
Karsten Hopp 6c1ae6
Karsten Hopp 6c1ae6
-- 
Karsten Hopp 6c1ae6
Momento mori, ergo carpe diem
Karsten Hopp 6c1ae6
Karsten Hopp 6c1ae6
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 6c1ae6
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 6c1ae6
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 6c1ae6
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///