Patch 7.4.1707
Problem:    Cannot use empty dictionary key, even though it can be useful.
Solution:   Allow using an empty dictionary key.
Files:      src/hashtab.c, src/eval.c, src/testdir/test_expr.vim


*** ../vim-7.4.1706/src/hashtab.c       2016-01-30 17:24:01.798502450 +0100
--- src/hashtab.c       2016-04-03 22:26:34.062780124 +0200
***************
*** 468,475 ****
      char_u    *p;
  
      if ((hash = *key) == 0)
!       return (hash_T)0;       /* Empty keys are not allowed, but we don't
!                                  want to crash if we get one. */
      p = key + 1;
  
      /* A simplistic algorithm that appears to do very well.
--- 468,474 ----
      char_u    *p;
  
      if ((hash = *key) == 0)
!       return (hash_T)0;
      p = key + 1;
  
      /* A simplistic algorithm that appears to do very well.
*** ../vim-7.4.1706/src/eval.c  2016-04-03 20:57:17.009726516 +0200
--- src/eval.c  2016-04-03 22:29:33.180933454 +0200
***************
*** 2782,2792 ****
            if (len == -1)
            {
                /* "[key]": get key from "var1" */
!               key = get_tv_string(&var1);     /* is number or string */
!               if (*key == NUL)
                {
-                   if (!quiet)
-                       EMSG(_(e_emptykey));
                    clear_tv(&var1);
                    return NULL;
                }
--- 2782,2790 ----
            if (len == -1)
            {
                /* "[key]": get key from "var1" */
!               key = get_tv_string_chk(&var1); /* is number or string */
!               if (key == NULL)
                {
                    clear_tv(&var1);
                    return NULL;
                }
***************
*** 5623,5633 ****
  
                    if (len == -1)
                    {
!                       key = get_tv_string(&var1);
!                       if (*key == NUL)
                        {
-                           if (verbose)
-                               EMSG(_(e_emptykey));
                            clear_tv(&var1);
                            return FAIL;
                        }
--- 5621,5629 ----
  
                    if (len == -1)
                    {
!                       key = get_tv_string_chk(&var1);
!                       if (key == NULL)
                        {
                            clear_tv(&var1);
                            return FAIL;
                        }
***************
*** 7754,7764 ****
        if (evaluate)
        {
            key = get_tv_string_buf_chk(&tvkey, buf);
!           if (key == NULL || *key == NUL)
            {
                /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */
-               if (key != NULL)
-                   EMSG(_(e_emptykey));
                clear_tv(&tvkey);
                goto failret;
            }
--- 7750,7758 ----
        if (evaluate)
        {
            key = get_tv_string_buf_chk(&tvkey, buf);
!           if (key == NULL)
            {
                /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */
                clear_tv(&tvkey);
                goto failret;
            }
*** ../vim-7.4.1706/src/testdir/test_expr.vim   2016-03-26 21:24:10.548534905 
+0100
--- src/testdir/test_expr.vim   2016-04-03 22:41:36.377446837 +0200
***************
*** 36,38 ****
--- 36,52 ----
    call assert_false(has('patch-9.1.0'))
    call assert_false(has('patch-9.9.1'))
  endfunc
+ 
+ func Test_dict()
+   let d = {'': 'empty', 'a': 'a', 0: 'zero'}
+   call assert_equal('empty', d[''])
+   call assert_equal('a', d['a'])
+   call assert_equal('zero', d[0])
+   call assert_true(has_key(d, ''))
+   call assert_true(has_key(d, 'a'))
+ 
+   let d[''] = 'none'
+   let d['a'] = 'aaa'
+   call assert_equal('none', d[''])
+   call assert_equal('aaa', d['a'])
+ endfunc
*** ../vim-7.4.1706/src/version.c       2016-04-03 22:22:25.353340490 +0200
--- src/version.c       2016-04-03 22:35:56.664962615 +0200
***************
*** 750,751 ****
--- 750,753 ----
  {   /* Add new patch number below this line */
+ /**/
+     1707,
  /**/

-- 
msdn.microsoft.com:
ERROR_SUCCESS 0 (0x0) The operation completed successfully.
I have always suspected that for Microsoft success is an error.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui