Karsten Hopp e2a814
To: vim-dev@vim.org
Karsten Hopp e2a814
Subject: Patch 7.2.333
Karsten Hopp e2a814
Fcc: outbox
Karsten Hopp e2a814
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp e2a814
Mime-Version: 1.0
Karsten Hopp e2a814
Content-Type: text/plain; charset=UTF-8
Karsten Hopp e2a814
Content-Transfer-Encoding: 8bit
Karsten Hopp e2a814
------------
Karsten Hopp e2a814
Karsten Hopp e2a814
Patch 7.2.333
Karsten Hopp e2a814
Problem:    Warnings from static code analysis.
Karsten Hopp e2a814
Solution:   Small changes to various lines. (Dominique Pelle)
Karsten Hopp e2a814
Files:	    src/buffer.c, src/edit.c, src/ex_getln.c, src/fileio.c,
Karsten Hopp e2a814
	    src/if_cscope.c, src/netbeans.c, src/ops.c, src/quickfix.c,
Karsten Hopp e2a814
	    src/syntax.c, src/ui.c
Karsten Hopp e2a814
Karsten Hopp e2a814
Karsten Hopp e2a814
*** ../vim-7.2.332/src/buffer.c	2009-05-17 13:30:58.000000000 +0200
Karsten Hopp e2a814
--- src/buffer.c	2010-01-19 12:50:24.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 315,321 ****
Karsten Hopp e2a814
  {
Karsten Hopp e2a814
  #ifdef FEAT_AUTOCMD
Karsten Hopp e2a814
      int		is_curbuf;
Karsten Hopp e2a814
!     int		nwindows = buf->b_nwindows;
Karsten Hopp e2a814
  #endif
Karsten Hopp e2a814
      int		unload_buf = (action != 0);
Karsten Hopp e2a814
      int		del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
Karsten Hopp e2a814
--- 315,321 ----
Karsten Hopp e2a814
  {
Karsten Hopp e2a814
  #ifdef FEAT_AUTOCMD
Karsten Hopp e2a814
      int		is_curbuf;
Karsten Hopp e2a814
!     int		nwindows;
Karsten Hopp e2a814
  #endif
Karsten Hopp e2a814
      int		unload_buf = (action != 0);
Karsten Hopp e2a814
      int		del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
Karsten Hopp e2a814
*** ../vim-7.2.332/src/edit.c	2009-12-24 15:45:53.000000000 +0100
Karsten Hopp e2a814
--- src/edit.c	2010-01-19 12:53:18.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 4048,4054 ****
Karsten Hopp e2a814
  	    save_p_ic = p_ic;
Karsten Hopp e2a814
  	    p_ic = ignorecase(compl_pattern);
Karsten Hopp e2a814
  
Karsten Hopp e2a814
! 	    /* Find up to TAG_MANY matches.  Avoids that an enourmous number
Karsten Hopp e2a814
  	     * of matches is found when compl_pattern is empty */
Karsten Hopp e2a814
  	    if (find_tags(compl_pattern, &num_matches, &matches,
Karsten Hopp e2a814
  		    TAG_REGEXP | TAG_NAMES | TAG_NOIC |
Karsten Hopp e2a814
--- 4048,4054 ----
Karsten Hopp e2a814
  	    save_p_ic = p_ic;
Karsten Hopp e2a814
  	    p_ic = ignorecase(compl_pattern);
Karsten Hopp e2a814
  
Karsten Hopp e2a814
! 	    /* Find up to TAG_MANY matches.  Avoids that an enormous number
Karsten Hopp e2a814
  	     * of matches is found when compl_pattern is empty */
Karsten Hopp e2a814
  	    if (find_tags(compl_pattern, &num_matches, &matches,
Karsten Hopp e2a814
  		    TAG_REGEXP | TAG_NAMES | TAG_NOIC |
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 4219,4225 ****
Karsten Hopp e2a814
  						 || IObuff[len - 2] == '!'))))
Karsten Hopp e2a814
  					IObuff[len++] = ' ';
Karsten Hopp e2a814
  				}
Karsten Hopp e2a814
! 				/* copy as much as posible of the new word */
Karsten Hopp e2a814
  				if (tmp_ptr - ptr >= IOSIZE - len)
Karsten Hopp e2a814
  				    tmp_ptr = ptr + IOSIZE - len - 1;
Karsten Hopp e2a814
  				STRNCPY(IObuff + len, ptr, tmp_ptr - ptr);
Karsten Hopp e2a814
--- 4219,4225 ----
Karsten Hopp e2a814
  						 || IObuff[len - 2] == '!'))))
Karsten Hopp e2a814
  					IObuff[len++] = ' ';
Karsten Hopp e2a814
  				}
Karsten Hopp e2a814
! 				/* copy as much as possible of the new word */
Karsten Hopp e2a814
  				if (tmp_ptr - ptr >= IOSIZE - len)
Karsten Hopp e2a814
  				    tmp_ptr = ptr + IOSIZE - len - 1;
Karsten Hopp e2a814
  				STRNCPY(IObuff + len, ptr, tmp_ptr - ptr);
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 5827,5836 ****
Karsten Hopp e2a814
  #endif
Karsten Hopp e2a814
  		&& !has_format_option(FO_WRAP))
Karsten Hopp e2a814
  
Karsten Hopp e2a814
- 	{
Karsten Hopp e2a814
- 	    textwidth = 0;
Karsten Hopp e2a814
  	    break;
Karsten Hopp e2a814
- 	}
Karsten Hopp e2a814
  	if ((startcol = curwin->w_cursor.col) == 0)
Karsten Hopp e2a814
  	    break;
Karsten Hopp e2a814
  
Karsten Hopp e2a814
--- 5827,5833 ----
Karsten Hopp e2a814
*** ../vim-7.2.332/src/ex_getln.c	2009-12-02 17:15:04.000000000 +0100
Karsten Hopp e2a814
--- src/ex_getln.c	2010-01-19 12:54:47.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 2193,2199 ****
Karsten Hopp e2a814
      {
Karsten Hopp e2a814
  	if (ga_grow(&line_ga, 40) == FAIL)
Karsten Hopp e2a814
  	    break;
Karsten Hopp e2a814
- 	pend = (char_u *)line_ga.ga_data + line_ga.ga_len;
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  	/* Get one character at a time.  Don't use inchar(), it can't handle
Karsten Hopp e2a814
  	 * special characters. */
Karsten Hopp e2a814
--- 2193,2198 ----
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 3314,3320 ****
Karsten Hopp e2a814
  		    WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE
Karsten Hopp e2a814
  							      |options, type);
Karsten Hopp e2a814
  	    vim_free(p1);
Karsten Hopp e2a814
! 	    /* longest match: make sure it is not shorter (happens with :help */
Karsten Hopp e2a814
  	    if (p2 != NULL && type == WILD_LONGEST)
Karsten Hopp e2a814
  	    {
Karsten Hopp e2a814
  		for (j = 0; j < xp->xp_pattern_len; ++j)
Karsten Hopp e2a814
--- 3313,3319 ----
Karsten Hopp e2a814
  		    WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE
Karsten Hopp e2a814
  							      |options, type);
Karsten Hopp e2a814
  	    vim_free(p1);
Karsten Hopp e2a814
! 	    /* longest match: make sure it is not shorter, happens with :help */
Karsten Hopp e2a814
  	    if (p2 != NULL && type == WILD_LONGEST)
Karsten Hopp e2a814
  	    {
Karsten Hopp e2a814
  		for (j = 0; j < xp->xp_pattern_len; ++j)
Karsten Hopp e2a814
*** ../vim-7.2.332/src/fileio.c	2009-12-31 14:52:48.000000000 +0100
Karsten Hopp e2a814
--- src/fileio.c	2010-01-19 12:56:59.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 7072,7079 ****
Karsten Hopp e2a814
  	 */
Karsten Hopp e2a814
  	for (i = 0; i < (int)(sizeof(tempdirs) / sizeof(char *)); ++i)
Karsten Hopp e2a814
  	{
Karsten Hopp e2a814
- 	    size_t	itmplen;
Karsten Hopp e2a814
  # ifndef HAVE_MKDTEMP
Karsten Hopp e2a814
  	    long	nr;
Karsten Hopp e2a814
  	    long	off;
Karsten Hopp e2a814
  # endif
Karsten Hopp e2a814
--- 7072,7079 ----
Karsten Hopp e2a814
  	 */
Karsten Hopp e2a814
  	for (i = 0; i < (int)(sizeof(tempdirs) / sizeof(char *)); ++i)
Karsten Hopp e2a814
  	{
Karsten Hopp e2a814
  # ifndef HAVE_MKDTEMP
Karsten Hopp e2a814
+ 	    size_t	itmplen;
Karsten Hopp e2a814
  	    long	nr;
Karsten Hopp e2a814
  	    long	off;
Karsten Hopp e2a814
  # endif
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 7091,7097 ****
Karsten Hopp e2a814
  		else
Karsten Hopp e2a814
  # endif
Karsten Hopp e2a814
  		    add_pathsep(itmp);
Karsten Hopp e2a814
- 		itmplen = STRLEN(itmp);
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  # ifdef HAVE_MKDTEMP
Karsten Hopp e2a814
  		/* Leave room for filename */
Karsten Hopp e2a814
--- 7091,7096 ----
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 7104,7109 ****
Karsten Hopp e2a814
--- 7103,7109 ----
Karsten Hopp e2a814
  		 * otherwise it doesn't matter.  The use of mkdir() avoids any
Karsten Hopp e2a814
  		 * security problems because of the predictable number. */
Karsten Hopp e2a814
  		nr = (mch_get_pid() + (long)time(NULL)) % 1000000L;
Karsten Hopp e2a814
+ 		itmplen = STRLEN(itmp);
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  		/* Try up to 10000 different values until we find a name that
Karsten Hopp e2a814
  		 * doesn't exist. */
Karsten Hopp e2a814
*** ../vim-7.2.332/src/if_cscope.c	2009-07-09 21:22:36.000000000 +0200
Karsten Hopp e2a814
--- src/if_cscope.c	2010-01-19 12:57:58.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 2069,2075 ****
Karsten Hopp e2a814
  	    continue;
Karsten Hopp e2a814
  	(void)strcpy(tbuf, matches[idx]);
Karsten Hopp e2a814
  
Karsten Hopp e2a814
! 	if ((fname = strtok(tbuf, (const char *)"\t")) == NULL)
Karsten Hopp e2a814
  	    continue;
Karsten Hopp e2a814
  	if ((fname = strtok(NULL, (const char *)"\t")) == NULL)
Karsten Hopp e2a814
  	    continue;
Karsten Hopp e2a814
--- 2069,2075 ----
Karsten Hopp e2a814
  	    continue;
Karsten Hopp e2a814
  	(void)strcpy(tbuf, matches[idx]);
Karsten Hopp e2a814
  
Karsten Hopp e2a814
! 	if (strtok(tbuf, (const char *)"\t") == NULL)
Karsten Hopp e2a814
  	    continue;
Karsten Hopp e2a814
  	if ((fname = strtok(NULL, (const char *)"\t")) == NULL)
Karsten Hopp e2a814
  	    continue;
Karsten Hopp e2a814
*** ../vim-7.2.332/src/netbeans.c	2009-09-11 14:19:41.000000000 +0200
Karsten Hopp e2a814
--- src/netbeans.c	2010-01-19 13:57:11.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 873,879 ****
Karsten Hopp e2a814
      {
Karsten Hopp e2a814
  #ifdef NBDEBUG
Karsten Hopp e2a814
  	/*
Karsten Hopp e2a814
! 	 * This happens because the ExtEd can send a cammand or 2 after
Karsten Hopp e2a814
  	 * doing a stopDocumentListen command. It doesn't harm anything
Karsten Hopp e2a814
  	 * so I'm disabling it except for debugging.
Karsten Hopp e2a814
  	 */
Karsten Hopp e2a814
--- 883,889 ----
Karsten Hopp e2a814
      {
Karsten Hopp e2a814
  #ifdef NBDEBUG
Karsten Hopp e2a814
  	/*
Karsten Hopp e2a814
! 	 * This happens because the ExtEd can send a command or 2 after
Karsten Hopp e2a814
  	 * doing a stopDocumentListen command. It doesn't harm anything
Karsten Hopp e2a814
  	 * so I'm disabling it except for debugging.
Karsten Hopp e2a814
  	 */
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 1174,1180 ****
Karsten Hopp e2a814
  		break;
Karsten Hopp e2a814
  	}
Karsten Hopp e2a814
      }
Karsten Hopp e2a814
!     *q++ = '\0';
Karsten Hopp e2a814
  
Karsten Hopp e2a814
      return buf;
Karsten Hopp e2a814
  }
Karsten Hopp e2a814
--- 1184,1190 ----
Karsten Hopp e2a814
  		break;
Karsten Hopp e2a814
  	}
Karsten Hopp e2a814
      }
Karsten Hopp e2a814
!     *q = '\0';
Karsten Hopp e2a814
  
Karsten Hopp e2a814
      return buf;
Karsten Hopp e2a814
  }
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 3070,3076 ****
Karsten Hopp e2a814
  }
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  /*
Karsten Hopp e2a814
!  * Send netbeans an unmodufied command.
Karsten Hopp e2a814
   */
Karsten Hopp e2a814
      void
Karsten Hopp e2a814
  netbeans_unmodified(buf_T *bufp UNUSED)
Karsten Hopp e2a814
--- 3080,3086 ----
Karsten Hopp e2a814
  }
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  /*
Karsten Hopp e2a814
!  * Send netbeans an unmodified command.
Karsten Hopp e2a814
   */
Karsten Hopp e2a814
      void
Karsten Hopp e2a814
  netbeans_unmodified(buf_T *bufp UNUSED)
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 3366,3372 ****
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  /*
Karsten Hopp e2a814
!  * Add a sign of the reqested type at the requested location.
Karsten Hopp e2a814
   *
Karsten Hopp e2a814
   * Reverse engineering:
Karsten Hopp e2a814
   * Apparently an annotation is defined the first time it is used in a buffer.
Karsten Hopp e2a814
--- 3380,3386 ----
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  /*
Karsten Hopp e2a814
!  * Add a sign of the requested type at the requested location.
Karsten Hopp e2a814
   *
Karsten Hopp e2a814
   * Reverse engineering:
Karsten Hopp e2a814
   * Apparently an annotation is defined the first time it is used in a buffer.
Karsten Hopp e2a814
*** ../vim-7.2.332/src/ops.c	2009-11-25 12:38:49.000000000 +0100
Karsten Hopp e2a814
--- src/ops.c	2010-01-19 13:04:46.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 5591,5603 ****
Karsten Hopp e2a814
  	 */
Karsten Hopp e2a814
  	if (has_mbyte)
Karsten Hopp e2a814
  	{
Karsten Hopp e2a814
- 	    char_u	*conv_str = str;
Karsten Hopp e2a814
  	    vimconv_T	vc;
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  	    vc.vc_type = CONV_NONE;
Karsten Hopp e2a814
  	    if (convert_setup(&vc, p_enc, (char_u *)"latin1") == OK)
Karsten Hopp e2a814
  	    {
Karsten Hopp e2a814
! 	        int intlen = len;
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  		conv_str = string_convert(&vc, str, &intlen);
Karsten Hopp e2a814
  		len = intlen;
Karsten Hopp e2a814
--- 5598,5610 ----
Karsten Hopp e2a814
  	 */
Karsten Hopp e2a814
  	if (has_mbyte)
Karsten Hopp e2a814
  	{
Karsten Hopp e2a814
  	    vimconv_T	vc;
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  	    vc.vc_type = CONV_NONE;
Karsten Hopp e2a814
  	    if (convert_setup(&vc, p_enc, (char_u *)"latin1") == OK)
Karsten Hopp e2a814
  	    {
Karsten Hopp e2a814
! 		int	intlen = len;
Karsten Hopp e2a814
! 		char_u	*conv_str;
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  		conv_str = string_convert(&vc, str, &intlen);
Karsten Hopp e2a814
  		len = intlen;
Karsten Hopp e2a814
*** ../vim-7.2.332/src/quickfix.c	2009-06-24 17:31:27.000000000 +0200
Karsten Hopp e2a814
--- src/quickfix.c	2010-01-19 13:12:29.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 1899,1905 ****
Karsten Hopp e2a814
      int		i;
Karsten Hopp e2a814
      int		idx1 = 1;
Karsten Hopp e2a814
      int		idx2 = -1;
Karsten Hopp e2a814
-     int		need_return = TRUE;
Karsten Hopp e2a814
      char_u	*arg = eap->arg;
Karsten Hopp e2a814
      int		all = eap->forceit;	/* if not :cl!, only show
Karsten Hopp e2a814
  						   recognised errors */
Karsten Hopp e2a814
--- 1899,1904 ----
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 1939,1951 ****
Karsten Hopp e2a814
      {
Karsten Hopp e2a814
  	if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
Karsten Hopp e2a814
  	{
Karsten Hopp e2a814
! 	    if (need_return)
Karsten Hopp e2a814
! 	    {
Karsten Hopp e2a814
! 		msg_putchar('\n');
Karsten Hopp e2a814
! 		if (got_int)
Karsten Hopp e2a814
! 		    break;
Karsten Hopp e2a814
! 		need_return = FALSE;
Karsten Hopp e2a814
! 	    }
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  	    fname = NULL;
Karsten Hopp e2a814
  	    if (qfp->qf_fnum != 0
Karsten Hopp e2a814
--- 1938,1946 ----
Karsten Hopp e2a814
      {
Karsten Hopp e2a814
  	if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
Karsten Hopp e2a814
  	{
Karsten Hopp e2a814
! 	    msg_putchar('\n');
Karsten Hopp e2a814
! 	    if (got_int)
Karsten Hopp e2a814
! 		break;
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  	    fname = NULL;
Karsten Hopp e2a814
  	    if (qfp->qf_fnum != 0
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 1988,1994 ****
Karsten Hopp e2a814
  							      IObuff, IOSIZE);
Karsten Hopp e2a814
  	    msg_prt_line(IObuff, FALSE);
Karsten Hopp e2a814
  	    out_flush();		/* show one line at a time */
Karsten Hopp e2a814
- 	    need_return = TRUE;
Karsten Hopp e2a814
  	}
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  	qfp = qfp->qf_next;
Karsten Hopp e2a814
--- 1983,1988 ----
Karsten Hopp e2a814
*** ../vim-7.2.332/src/syntax.c	2009-12-16 18:13:04.000000000 +0100
Karsten Hopp e2a814
--- src/syntax.c	2010-01-19 13:12:56.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 4167,4173 ****
Karsten Hopp e2a814
  	if (!HASHITEM_EMPTY(hi))
Karsten Hopp e2a814
  	{
Karsten Hopp e2a814
  	    --todo;
Karsten Hopp e2a814
- 	    kp = HI2KE(hi);
Karsten Hopp e2a814
  	    for (kp = HI2KE(hi); kp != NULL; kp = kp_next)
Karsten Hopp e2a814
  	    {
Karsten Hopp e2a814
  		kp_next = kp->ke_next;
Karsten Hopp e2a814
--- 4167,4172 ----
Karsten Hopp e2a814
*** ../vim-7.2.332/src/ui.c	2009-09-11 16:48:06.000000000 +0200
Karsten Hopp e2a814
--- src/ui.c	2010-01-19 13:14:04.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 2383,2389 ****
Karsten Hopp e2a814
  	 * 'enc' anyway. */
Karsten Hopp e2a814
  	if (has_mbyte)
Karsten Hopp e2a814
  	{
Karsten Hopp e2a814
! 	    char_u	*conv_buf = buffer;
Karsten Hopp e2a814
  	    vimconv_T	vc;
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  	    vc.vc_type = CONV_NONE;
Karsten Hopp e2a814
--- 2383,2389 ----
Karsten Hopp e2a814
  	 * 'enc' anyway. */
Karsten Hopp e2a814
  	if (has_mbyte)
Karsten Hopp e2a814
  	{
Karsten Hopp e2a814
! 	    char_u	*conv_buf;
Karsten Hopp e2a814
  	    vimconv_T	vc;
Karsten Hopp e2a814
  
Karsten Hopp e2a814
  	    vc.vc_type = CONV_NONE;
Karsten Hopp e2a814
*** ../vim-7.2.332/src/version.c	2010-01-19 13:06:42.000000000 +0100
Karsten Hopp e2a814
--- src/version.c	2010-01-19 14:55:50.000000000 +0100
Karsten Hopp e2a814
***************
Karsten Hopp e2a814
*** 683,684 ****
Karsten Hopp e2a814
--- 683,686 ----
Karsten Hopp e2a814
  {   /* Add new patch number below this line */
Karsten Hopp e2a814
+ /**/
Karsten Hopp e2a814
+     333,
Karsten Hopp e2a814
  /**/
Karsten Hopp e2a814
Karsten Hopp e2a814
-- 
Karsten Hopp e2a814
An actual excerpt from a classified section of a city newspaper:
Karsten Hopp e2a814
"Illiterate?  Write today for free help!"
Karsten Hopp e2a814
Karsten Hopp e2a814
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp e2a814
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp e2a814
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp e2a814
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///