Karsten Hopp fdc679
To: vim_dev@googlegroups.com
Karsten Hopp fdc679
Subject: Patch 7.3.677
Karsten Hopp fdc679
Fcc: outbox
Karsten Hopp fdc679
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp fdc679
Mime-Version: 1.0
Karsten Hopp fdc679
Content-Type: text/plain; charset=UTF-8
Karsten Hopp fdc679
Content-Transfer-Encoding: 8bit
Karsten Hopp fdc679
------------
Karsten Hopp fdc679
Karsten Hopp fdc679
Patch 7.3.677
Karsten Hopp fdc679
Problem:    buf_spname() is used inconsistently.
Karsten Hopp fdc679
Solution:   Make the return type a char_u pointer.  Check the size of the
Karsten Hopp fdc679
	    returned string.
Karsten Hopp fdc679
Files:	    src/buffer.c, src/proto/buffer.pro, src/ex_cmds2.c,
Karsten Hopp fdc679
	    src/ex_docmd.c, src/memline.c, src/screen.c
Karsten Hopp fdc679
Karsten Hopp fdc679
Karsten Hopp fdc679
*** ../vim-7.3.676/src/buffer.c	2012-10-03 17:12:43.000000000 +0200
Karsten Hopp fdc679
--- src/buffer.c	2012-10-03 18:14:34.000000000 +0200
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 2635,2641 ****
Karsten Hopp fdc679
  	    continue;
Karsten Hopp fdc679
  	msg_putchar('\n');
Karsten Hopp fdc679
  	if (buf_spname(buf) != NULL)
Karsten Hopp fdc679
! 	    STRCPY(NameBuff, buf_spname(buf));
Karsten Hopp fdc679
  	else
Karsten Hopp fdc679
  	    home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
Karsten Hopp fdc679
  
Karsten Hopp fdc679
--- 2635,2641 ----
Karsten Hopp fdc679
  	    continue;
Karsten Hopp fdc679
  	msg_putchar('\n');
Karsten Hopp fdc679
  	if (buf_spname(buf) != NULL)
Karsten Hopp fdc679
! 	    vim_strncpy(NameBuff, buf_spname(buf), MAXPATHL - 1);
Karsten Hopp fdc679
  	else
Karsten Hopp fdc679
  	    home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
Karsten Hopp fdc679
  
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 3350,3356 ****
Karsten Hopp fdc679
  	else
Karsten Hopp fdc679
  	{
Karsten Hopp fdc679
  	    if (buf_spname(curbuf) != NULL)
Karsten Hopp fdc679
! 		i_name = (char_u *)buf_spname(curbuf);
Karsten Hopp fdc679
  	    else		    /* use file name only in icon */
Karsten Hopp fdc679
  		i_name = gettail(curbuf->b_ffname);
Karsten Hopp fdc679
  	    *i_str = NUL;
Karsten Hopp fdc679
--- 3350,3356 ----
Karsten Hopp fdc679
  	else
Karsten Hopp fdc679
  	{
Karsten Hopp fdc679
  	    if (buf_spname(curbuf) != NULL)
Karsten Hopp fdc679
! 		i_name = buf_spname(curbuf);
Karsten Hopp fdc679
  	    else		    /* use file name only in icon */
Karsten Hopp fdc679
  		i_name = gettail(curbuf->b_ffname);
Karsten Hopp fdc679
  	    *i_str = NUL;
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 3766,3772 ****
Karsten Hopp fdc679
  	case STL_FILENAME:
Karsten Hopp fdc679
  	    fillable = FALSE;	/* don't change ' ' to fillchar */
Karsten Hopp fdc679
  	    if (buf_spname(wp->w_buffer) != NULL)
Karsten Hopp fdc679
! 		STRCPY(NameBuff, buf_spname(wp->w_buffer));
Karsten Hopp fdc679
  	    else
Karsten Hopp fdc679
  	    {
Karsten Hopp fdc679
  		t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname
Karsten Hopp fdc679
--- 3766,3772 ----
Karsten Hopp fdc679
  	case STL_FILENAME:
Karsten Hopp fdc679
  	    fillable = FALSE;	/* don't change ' ' to fillchar */
Karsten Hopp fdc679
  	    if (buf_spname(wp->w_buffer) != NULL)
Karsten Hopp fdc679
! 		vim_strncpy(NameBuff, buf_spname(wp->w_buffer), MAXPATHL - 1);
Karsten Hopp fdc679
  	    else
Karsten Hopp fdc679
  	    {
Karsten Hopp fdc679
  		t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 5244,5250 ****
Karsten Hopp fdc679
   * Return special buffer name.
Karsten Hopp fdc679
   * Returns NULL when the buffer has a normal file name.
Karsten Hopp fdc679
   */
Karsten Hopp fdc679
!     char *
Karsten Hopp fdc679
  buf_spname(buf)
Karsten Hopp fdc679
      buf_T	*buf;
Karsten Hopp fdc679
  {
Karsten Hopp fdc679
--- 5244,5250 ----
Karsten Hopp fdc679
   * Return special buffer name.
Karsten Hopp fdc679
   * Returns NULL when the buffer has a normal file name.
Karsten Hopp fdc679
   */
Karsten Hopp fdc679
!     char_u *
Karsten Hopp fdc679
  buf_spname(buf)
Karsten Hopp fdc679
      buf_T	*buf;
Karsten Hopp fdc679
  {
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 5263,5271 ****
Karsten Hopp fdc679
  		goto win_found;
Karsten Hopp fdc679
  win_found:
Karsten Hopp fdc679
  	if (win != NULL && win->w_llist_ref != NULL)
Karsten Hopp fdc679
! 	    return _(msg_loclist);
Karsten Hopp fdc679
  	else
Karsten Hopp fdc679
! 	    return _(msg_qflist);
Karsten Hopp fdc679
      }
Karsten Hopp fdc679
  #endif
Karsten Hopp fdc679
  #ifdef FEAT_QUICKFIX
Karsten Hopp fdc679
--- 5263,5271 ----
Karsten Hopp fdc679
  		goto win_found;
Karsten Hopp fdc679
  win_found:
Karsten Hopp fdc679
  	if (win != NULL && win->w_llist_ref != NULL)
Karsten Hopp fdc679
! 	    return (char_u *)_(msg_loclist);
Karsten Hopp fdc679
  	else
Karsten Hopp fdc679
! 	    return (char_u *)_(msg_qflist);
Karsten Hopp fdc679
      }
Karsten Hopp fdc679
  #endif
Karsten Hopp fdc679
  #ifdef FEAT_QUICKFIX
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 5274,5285 ****
Karsten Hopp fdc679
      if (bt_nofile(buf))
Karsten Hopp fdc679
      {
Karsten Hopp fdc679
  	if (buf->b_sfname != NULL)
Karsten Hopp fdc679
! 	    return (char *)buf->b_sfname;
Karsten Hopp fdc679
! 	return _("[Scratch]");
Karsten Hopp fdc679
      }
Karsten Hopp fdc679
  #endif
Karsten Hopp fdc679
      if (buf->b_fname == NULL)
Karsten Hopp fdc679
! 	return _("[No Name]");
Karsten Hopp fdc679
      return NULL;
Karsten Hopp fdc679
  }
Karsten Hopp fdc679
  
Karsten Hopp fdc679
--- 5274,5285 ----
Karsten Hopp fdc679
      if (bt_nofile(buf))
Karsten Hopp fdc679
      {
Karsten Hopp fdc679
  	if (buf->b_sfname != NULL)
Karsten Hopp fdc679
! 	    return buf->b_sfname;
Karsten Hopp fdc679
! 	return (char_u *)_("[Scratch]");
Karsten Hopp fdc679
      }
Karsten Hopp fdc679
  #endif
Karsten Hopp fdc679
      if (buf->b_fname == NULL)
Karsten Hopp fdc679
! 	return (char_u *)_("[No Name]");
Karsten Hopp fdc679
      return NULL;
Karsten Hopp fdc679
  }
Karsten Hopp fdc679
  
Karsten Hopp fdc679
*** ../vim-7.3.676/src/proto/buffer.pro	2012-07-10 15:18:18.000000000 +0200
Karsten Hopp fdc679
--- src/proto/buffer.pro	2012-10-03 18:17:58.000000000 +0200
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 51,57 ****
Karsten Hopp fdc679
  void do_modelines __ARGS((int flags));
Karsten Hopp fdc679
  int read_viminfo_bufferlist __ARGS((vir_T *virp, int writing));
Karsten Hopp fdc679
  void write_viminfo_bufferlist __ARGS((FILE *fp));
Karsten Hopp fdc679
! char *buf_spname __ARGS((buf_T *buf));
Karsten Hopp fdc679
  void buf_addsign __ARGS((buf_T *buf, int id, linenr_T lnum, int typenr));
Karsten Hopp fdc679
  linenr_T buf_change_sign_type __ARGS((buf_T *buf, int markId, int typenr));
Karsten Hopp fdc679
  int buf_getsigntype __ARGS((buf_T *buf, linenr_T lnum, int type));
Karsten Hopp fdc679
--- 51,57 ----
Karsten Hopp fdc679
  void do_modelines __ARGS((int flags));
Karsten Hopp fdc679
  int read_viminfo_bufferlist __ARGS((vir_T *virp, int writing));
Karsten Hopp fdc679
  void write_viminfo_bufferlist __ARGS((FILE *fp));
Karsten Hopp fdc679
! char_u *buf_spname __ARGS((buf_T *buf));
Karsten Hopp fdc679
  void buf_addsign __ARGS((buf_T *buf, int id, linenr_T lnum, int typenr));
Karsten Hopp fdc679
  linenr_T buf_change_sign_type __ARGS((buf_T *buf, int markId, int typenr));
Karsten Hopp fdc679
  int buf_getsigntype __ARGS((buf_T *buf, linenr_T lnum, int type));
Karsten Hopp fdc679
*** ../vim-7.3.676/src/ex_cmds2.c	2012-06-29 12:57:03.000000000 +0200
Karsten Hopp fdc679
--- src/ex_cmds2.c	2012-10-03 18:15:26.000000000 +0200
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 1688,1695 ****
Karsten Hopp fdc679
  	    msg_didout = FALSE;
Karsten Hopp fdc679
  	}
Karsten Hopp fdc679
  	if (EMSG2(_("E162: No write since last change for buffer \"%s\""),
Karsten Hopp fdc679
! 		    buf_spname(buf) != NULL ? (char_u *)buf_spname(buf) :
Karsten Hopp fdc679
! 		    buf->b_fname))
Karsten Hopp fdc679
  	{
Karsten Hopp fdc679
  	    save = no_wait_return;
Karsten Hopp fdc679
  	    no_wait_return = FALSE;
Karsten Hopp fdc679
--- 1688,1694 ----
Karsten Hopp fdc679
  	    msg_didout = FALSE;
Karsten Hopp fdc679
  	}
Karsten Hopp fdc679
  	if (EMSG2(_("E162: No write since last change for buffer \"%s\""),
Karsten Hopp fdc679
! 		    buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname))
Karsten Hopp fdc679
  	{
Karsten Hopp fdc679
  	    save = no_wait_return;
Karsten Hopp fdc679
  	    no_wait_return = FALSE;
Karsten Hopp fdc679
*** ../vim-7.3.676/src/ex_docmd.c	2012-09-18 16:47:00.000000000 +0200
Karsten Hopp fdc679
--- src/ex_docmd.c	2012-10-03 18:15:47.000000000 +0200
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 7602,7608 ****
Karsten Hopp fdc679
  	    msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' ');
Karsten Hopp fdc679
  	    msg_putchar(' ');
Karsten Hopp fdc679
  	    if (buf_spname(wp->w_buffer) != NULL)
Karsten Hopp fdc679
! 		STRCPY(IObuff, buf_spname(wp->w_buffer));
Karsten Hopp fdc679
  	    else
Karsten Hopp fdc679
  		home_replace(wp->w_buffer, wp->w_buffer->b_fname,
Karsten Hopp fdc679
  							IObuff, IOSIZE, TRUE);
Karsten Hopp fdc679
--- 7602,7608 ----
Karsten Hopp fdc679
  	    msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' ');
Karsten Hopp fdc679
  	    msg_putchar(' ');
Karsten Hopp fdc679
  	    if (buf_spname(wp->w_buffer) != NULL)
Karsten Hopp fdc679
! 		vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1);
Karsten Hopp fdc679
  	    else
Karsten Hopp fdc679
  		home_replace(wp->w_buffer, wp->w_buffer->b_fname,
Karsten Hopp fdc679
  							IObuff, IOSIZE, TRUE);
Karsten Hopp fdc679
*** ../vim-7.3.676/src/memline.c	2011-10-26 11:44:15.000000000 +0200
Karsten Hopp fdc679
--- src/memline.c	2012-10-03 18:18:23.000000000 +0200
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 780,788 ****
Karsten Hopp fdc679
  	need_wait_return = TRUE;	/* call wait_return later */
Karsten Hopp fdc679
  	++no_wait_return;
Karsten Hopp fdc679
  	(void)EMSG2(_("E303: Unable to open swap file for \"%s\", recovery impossible"),
Karsten Hopp fdc679
! 		    buf_spname(buf) != NULL
Karsten Hopp fdc679
! 			? (char_u *)buf_spname(buf)
Karsten Hopp fdc679
! 			: buf->b_fname);
Karsten Hopp fdc679
  	--no_wait_return;
Karsten Hopp fdc679
      }
Karsten Hopp fdc679
  
Karsten Hopp fdc679
--- 780,786 ----
Karsten Hopp fdc679
  	need_wait_return = TRUE;	/* call wait_return later */
Karsten Hopp fdc679
  	++no_wait_return;
Karsten Hopp fdc679
  	(void)EMSG2(_("E303: Unable to open swap file for \"%s\", recovery impossible"),
Karsten Hopp fdc679
! 		    buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname);
Karsten Hopp fdc679
  	--no_wait_return;
Karsten Hopp fdc679
      }
Karsten Hopp fdc679
  
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 1315,1321 ****
Karsten Hopp fdc679
      smsg((char_u *)_("Using swap file \"%s\""), NameBuff);
Karsten Hopp fdc679
  
Karsten Hopp fdc679
      if (buf_spname(curbuf) != NULL)
Karsten Hopp fdc679
! 	STRCPY(NameBuff, buf_spname(curbuf));
Karsten Hopp fdc679
      else
Karsten Hopp fdc679
  	home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, TRUE);
Karsten Hopp fdc679
      smsg((char_u *)_("Original file \"%s\""), NameBuff);
Karsten Hopp fdc679
--- 1313,1319 ----
Karsten Hopp fdc679
      smsg((char_u *)_("Using swap file \"%s\""), NameBuff);
Karsten Hopp fdc679
  
Karsten Hopp fdc679
      if (buf_spname(curbuf) != NULL)
Karsten Hopp fdc679
! 	vim_strncpy(NameBuff, buf_spname(curbuf), MAXPATHL - 1);
Karsten Hopp fdc679
      else
Karsten Hopp fdc679
  	home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, TRUE);
Karsten Hopp fdc679
      smsg((char_u *)_("Original file \"%s\""), NameBuff);
Karsten Hopp fdc679
*** ../vim-7.3.676/src/screen.c	2012-08-23 18:55:50.000000000 +0200
Karsten Hopp fdc679
--- src/screen.c	2012-10-03 18:17:25.000000000 +0200
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 9876,9882 ****
Karsten Hopp fdc679
      buf_T	*buf;
Karsten Hopp fdc679
  {
Karsten Hopp fdc679
      if (buf_spname(buf) != NULL)
Karsten Hopp fdc679
! 	STRCPY(NameBuff, buf_spname(buf));
Karsten Hopp fdc679
      else
Karsten Hopp fdc679
  	home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
Karsten Hopp fdc679
      trans_characters(NameBuff, MAXPATHL);
Karsten Hopp fdc679
--- 9876,9882 ----
Karsten Hopp fdc679
      buf_T	*buf;
Karsten Hopp fdc679
  {
Karsten Hopp fdc679
      if (buf_spname(buf) != NULL)
Karsten Hopp fdc679
! 	vim_strncpy(NameBuff, buf_spname(buf), MAXPATHL - 1);
Karsten Hopp fdc679
      else
Karsten Hopp fdc679
  	home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
Karsten Hopp fdc679
      trans_characters(NameBuff, MAXPATHL);
Karsten Hopp fdc679
*** ../vim-7.3.676/src/version.c	2012-10-03 18:06:55.000000000 +0200
Karsten Hopp fdc679
--- src/version.c	2012-10-03 18:22:18.000000000 +0200
Karsten Hopp fdc679
***************
Karsten Hopp fdc679
*** 721,722 ****
Karsten Hopp fdc679
--- 721,724 ----
Karsten Hopp fdc679
  {   /* Add new patch number below this line */
Karsten Hopp fdc679
+ /**/
Karsten Hopp fdc679
+     677,
Karsten Hopp fdc679
  /**/
Karsten Hopp fdc679
Karsten Hopp fdc679
-- 
Karsten Hopp fdc679
bashian roulette:
Karsten Hopp fdc679
$ ((RANDOM%6)) || rm -rf ~
Karsten Hopp fdc679
Karsten Hopp fdc679
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp fdc679
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp fdc679
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp fdc679
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///