Karsten Hopp 5b33a3
To: vim_dev@googlegroups.com
Karsten Hopp 5b33a3
Subject: Patch 7.3.740
Karsten Hopp 5b33a3
Fcc: outbox
Karsten Hopp 5b33a3
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 5b33a3
Mime-Version: 1.0
Karsten Hopp 5b33a3
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 5b33a3
Content-Transfer-Encoding: 8bit
Karsten Hopp 5b33a3
------------
Karsten Hopp 5b33a3
Karsten Hopp 5b33a3
Patch 7.3.740
Karsten Hopp 5b33a3
Problem:    IOC tool complains about undefined behavior for int.
Karsten Hopp 5b33a3
Solution:   Change to unsigned int. (Dominique Pelle)
Karsten Hopp 5b33a3
Files:	    src/hashtab.c, src/misc2.c
Karsten Hopp 5b33a3
Karsten Hopp 5b33a3
Karsten Hopp 5b33a3
*** ../vim-7.3.739/src/hashtab.c	2010-08-15 21:57:25.000000000 +0200
Karsten Hopp 5b33a3
--- src/hashtab.c	2012-11-28 18:27:46.000000000 +0100
Karsten Hopp 5b33a3
***************
Karsten Hopp 5b33a3
*** 138,144 ****
Karsten Hopp 5b33a3
      hash_T	perturb;
Karsten Hopp 5b33a3
      hashitem_T	*freeitem;
Karsten Hopp 5b33a3
      hashitem_T	*hi;
Karsten Hopp 5b33a3
!     int		idx;
Karsten Hopp 5b33a3
  
Karsten Hopp 5b33a3
  #ifdef HT_DEBUG
Karsten Hopp 5b33a3
      ++hash_count_lookup;
Karsten Hopp 5b33a3
--- 138,144 ----
Karsten Hopp 5b33a3
      hash_T	perturb;
Karsten Hopp 5b33a3
      hashitem_T	*freeitem;
Karsten Hopp 5b33a3
      hashitem_T	*hi;
Karsten Hopp 5b33a3
!     unsigned	idx;
Karsten Hopp 5b33a3
  
Karsten Hopp 5b33a3
  #ifdef HT_DEBUG
Karsten Hopp 5b33a3
      ++hash_count_lookup;
Karsten Hopp 5b33a3
***************
Karsten Hopp 5b33a3
*** 150,156 ****
Karsten Hopp 5b33a3
       * - skip over a removed item
Karsten Hopp 5b33a3
       * - return if the item matches
Karsten Hopp 5b33a3
       */
Karsten Hopp 5b33a3
!     idx = (int)(hash & ht->ht_mask);
Karsten Hopp 5b33a3
      hi = &ht->ht_array[idx];
Karsten Hopp 5b33a3
  
Karsten Hopp 5b33a3
      if (hi->hi_key == NULL)
Karsten Hopp 5b33a3
--- 150,156 ----
Karsten Hopp 5b33a3
       * - skip over a removed item
Karsten Hopp 5b33a3
       * - return if the item matches
Karsten Hopp 5b33a3
       */
Karsten Hopp 5b33a3
!     idx = (unsigned)(hash & ht->ht_mask);
Karsten Hopp 5b33a3
      hi = &ht->ht_array[idx];
Karsten Hopp 5b33a3
  
Karsten Hopp 5b33a3
      if (hi->hi_key == NULL)
Karsten Hopp 5b33a3
***************
Karsten Hopp 5b33a3
*** 176,182 ****
Karsten Hopp 5b33a3
  #ifdef HT_DEBUG
Karsten Hopp 5b33a3
  	++hash_count_perturb;	    /* count a "miss" for hashtab lookup */
Karsten Hopp 5b33a3
  #endif
Karsten Hopp 5b33a3
! 	idx = (int)((idx << 2) + idx + perturb + 1);
Karsten Hopp 5b33a3
  	hi = &ht->ht_array[idx & ht->ht_mask];
Karsten Hopp 5b33a3
  	if (hi->hi_key == NULL)
Karsten Hopp 5b33a3
  	    return freeitem == NULL ? hi : freeitem;
Karsten Hopp 5b33a3
--- 176,182 ----
Karsten Hopp 5b33a3
  #ifdef HT_DEBUG
Karsten Hopp 5b33a3
  	++hash_count_perturb;	    /* count a "miss" for hashtab lookup */
Karsten Hopp 5b33a3
  #endif
Karsten Hopp 5b33a3
! 	idx = (unsigned)((idx << 2U) + idx + perturb + 1U);
Karsten Hopp 5b33a3
  	hi = &ht->ht_array[idx & ht->ht_mask];
Karsten Hopp 5b33a3
  	if (hi->hi_key == NULL)
Karsten Hopp 5b33a3
  	    return freeitem == NULL ? hi : freeitem;
Karsten Hopp 5b33a3
***************
Karsten Hopp 5b33a3
*** 342,348 ****
Karsten Hopp 5b33a3
      hashitem_T	temparray[HT_INIT_SIZE];
Karsten Hopp 5b33a3
      hashitem_T	*oldarray, *newarray;
Karsten Hopp 5b33a3
      hashitem_T	*olditem, *newitem;
Karsten Hopp 5b33a3
!     int		newi;
Karsten Hopp 5b33a3
      int		todo;
Karsten Hopp 5b33a3
      long_u	oldsize, newsize;
Karsten Hopp 5b33a3
      long_u	minsize;
Karsten Hopp 5b33a3
--- 342,348 ----
Karsten Hopp 5b33a3
      hashitem_T	temparray[HT_INIT_SIZE];
Karsten Hopp 5b33a3
      hashitem_T	*oldarray, *newarray;
Karsten Hopp 5b33a3
      hashitem_T	*olditem, *newitem;
Karsten Hopp 5b33a3
!     unsigned	newi;
Karsten Hopp 5b33a3
      int		todo;
Karsten Hopp 5b33a3
      long_u	oldsize, newsize;
Karsten Hopp 5b33a3
      long_u	minsize;
Karsten Hopp 5b33a3
***************
Karsten Hopp 5b33a3
*** 448,460 ****
Karsten Hopp 5b33a3
  	     * the algorithm to find an item in hash_lookup().  But we only
Karsten Hopp 5b33a3
  	     * need to search for a NULL key, thus it's simpler.
Karsten Hopp 5b33a3
  	     */
Karsten Hopp 5b33a3
! 	    newi = (int)(olditem->hi_hash & newmask);
Karsten Hopp 5b33a3
  	    newitem = &newarray[newi];
Karsten Hopp 5b33a3
  
Karsten Hopp 5b33a3
  	    if (newitem->hi_key != NULL)
Karsten Hopp 5b33a3
  		for (perturb = olditem->hi_hash; ; perturb >>= PERTURB_SHIFT)
Karsten Hopp 5b33a3
  		{
Karsten Hopp 5b33a3
! 		    newi = (int)((newi << 2) + newi + perturb + 1);
Karsten Hopp 5b33a3
  		    newitem = &newarray[newi & newmask];
Karsten Hopp 5b33a3
  		    if (newitem->hi_key == NULL)
Karsten Hopp 5b33a3
  			break;
Karsten Hopp 5b33a3
--- 448,460 ----
Karsten Hopp 5b33a3
  	     * the algorithm to find an item in hash_lookup().  But we only
Karsten Hopp 5b33a3
  	     * need to search for a NULL key, thus it's simpler.
Karsten Hopp 5b33a3
  	     */
Karsten Hopp 5b33a3
! 	    newi = (unsigned)(olditem->hi_hash & newmask);
Karsten Hopp 5b33a3
  	    newitem = &newarray[newi];
Karsten Hopp 5b33a3
  
Karsten Hopp 5b33a3
  	    if (newitem->hi_key != NULL)
Karsten Hopp 5b33a3
  		for (perturb = olditem->hi_hash; ; perturb >>= PERTURB_SHIFT)
Karsten Hopp 5b33a3
  		{
Karsten Hopp 5b33a3
! 		    newi = (unsigned)((newi << 2U) + newi + perturb + 1U);
Karsten Hopp 5b33a3
  		    newitem = &newarray[newi & newmask];
Karsten Hopp 5b33a3
  		    if (newitem->hi_key == NULL)
Karsten Hopp 5b33a3
  			break;
Karsten Hopp 5b33a3
*** ../vim-7.3.739/src/misc2.c	2012-08-15 16:20:59.000000000 +0200
Karsten Hopp 5b33a3
--- src/misc2.c	2012-11-28 18:27:46.000000000 +0100
Karsten Hopp 5b33a3
***************
Karsten Hopp 5b33a3
*** 3860,3866 ****
Karsten Hopp 5b33a3
      ush temp; \
Karsten Hopp 5b33a3
   \
Karsten Hopp 5b33a3
      temp = (ush)keys[2] | 2; \
Karsten Hopp 5b33a3
!     t = (int)(((unsigned)(temp * (temp ^ 1)) >> 8) & 0xff); \
Karsten Hopp 5b33a3
  }
Karsten Hopp 5b33a3
  
Karsten Hopp 5b33a3
  /*
Karsten Hopp 5b33a3
--- 3860,3866 ----
Karsten Hopp 5b33a3
      ush temp; \
Karsten Hopp 5b33a3
   \
Karsten Hopp 5b33a3
      temp = (ush)keys[2] | 2; \
Karsten Hopp 5b33a3
!     t = (int)(((unsigned)(temp * (temp ^ 1U)) >> 8) & 0xff); \
Karsten Hopp 5b33a3
  }
Karsten Hopp 5b33a3
  
Karsten Hopp 5b33a3
  /*
Karsten Hopp 5b33a3
***************
Karsten Hopp 5b33a3
*** 4002,4008 ****
Karsten Hopp 5b33a3
  	    ush temp;
Karsten Hopp 5b33a3
  
Karsten Hopp 5b33a3
  	    temp = (ush)keys[2] | 2;
Karsten Hopp 5b33a3
! 	    temp = (int)(((unsigned)(temp * (temp ^ 1)) >> 8) & 0xff);
Karsten Hopp 5b33a3
  	    UPDATE_KEYS_ZIP(*p ^= temp);
Karsten Hopp 5b33a3
  	}
Karsten Hopp 5b33a3
      else
Karsten Hopp 5b33a3
--- 4002,4008 ----
Karsten Hopp 5b33a3
  	    ush temp;
Karsten Hopp 5b33a3
  
Karsten Hopp 5b33a3
  	    temp = (ush)keys[2] | 2;
Karsten Hopp 5b33a3
! 	    temp = (int)(((unsigned)(temp * (temp ^ 1U)) >> 8) & 0xff);
Karsten Hopp 5b33a3
  	    UPDATE_KEYS_ZIP(*p ^= temp);
Karsten Hopp 5b33a3
  	}
Karsten Hopp 5b33a3
      else
Karsten Hopp 5b33a3
*** ../vim-7.3.739/src/version.c	2012-11-28 18:22:04.000000000 +0100
Karsten Hopp 5b33a3
--- src/version.c	2012-11-28 18:28:00.000000000 +0100
Karsten Hopp 5b33a3
***************
Karsten Hopp 5b33a3
*** 727,728 ****
Karsten Hopp 5b33a3
--- 727,730 ----
Karsten Hopp 5b33a3
  {   /* Add new patch number below this line */
Karsten Hopp 5b33a3
+ /**/
Karsten Hopp 5b33a3
+     740,
Karsten Hopp 5b33a3
  /**/
Karsten Hopp 5b33a3
Karsten Hopp 5b33a3
-- 
Karsten Hopp 5b33a3
From "know your smileys":
Karsten Hopp 5b33a3
 ~#:-(	I just washed my hair, and I can't do nuthin' with it.
Karsten Hopp 5b33a3
Karsten Hopp 5b33a3
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 5b33a3
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 5b33a3
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 5b33a3
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///