Karsten Hopp 6ad10d
To: vim-dev@vim.org
Karsten Hopp 6ad10d
Subject: Patch 7.0.054
Karsten Hopp 6ad10d
Fcc: outbox
Karsten Hopp 6ad10d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 6ad10d
Mime-Version: 1.0
Karsten Hopp 6ad10d
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 6ad10d
Content-Transfer-Encoding: 8bit
Karsten Hopp 6ad10d
------------
Karsten Hopp 6ad10d
Karsten Hopp 6ad10d
Patch 7.0.054
Karsten Hopp 6ad10d
Problem:    Mac: Using a menu name that only has a mnemonic or accelerator
Karsten Hopp 6ad10d
	    causes a crash.  (Elliot Shank)
Karsten Hopp 6ad10d
Solution:   Check for an empty menu name.  Also delete empty submenus that
Karsten Hopp 6ad10d
	    were created before detecting the error.
Karsten Hopp 6ad10d
Files:	    src/menu.c
Karsten Hopp 6ad10d
Karsten Hopp 6ad10d
Karsten Hopp 6ad10d
*** ../vim-7.0.053/src/menu.c	Wed May  3 23:28:47 2006
Karsten Hopp 6ad10d
--- src/menu.c	Tue Aug  8 20:53:25 2006
Karsten Hopp 6ad10d
***************
Karsten Hopp 6ad10d
*** 511,516 ****
Karsten Hopp 6ad10d
--- 511,524 ----
Karsten Hopp 6ad10d
  	 * name (without mnemonic and accelerator text). */
Karsten Hopp 6ad10d
  	next_name = menu_name_skip(name);
Karsten Hopp 6ad10d
  	dname = menu_text(name, NULL, NULL);
Karsten Hopp 6ad10d
+ 	if (dname == NULL)
Karsten Hopp 6ad10d
+ 	    goto erret;
Karsten Hopp 6ad10d
+ 	if (*dname == NUL)
Karsten Hopp 6ad10d
+ 	{
Karsten Hopp 6ad10d
+ 	    /* Only a mnemonic or accelerator is not valid. */
Karsten Hopp 6ad10d
+ 	    EMSG(_("E792: Empty menu name"));
Karsten Hopp 6ad10d
+ 	    goto erret;
Karsten Hopp 6ad10d
+ 	}
Karsten Hopp 6ad10d
  
Karsten Hopp 6ad10d
  	/* See if it's already there */
Karsten Hopp 6ad10d
  	lower_pri = menup;
Karsten Hopp 6ad10d
***************
Karsten Hopp 6ad10d
*** 704,709 ****
Karsten Hopp 6ad10d
--- 712,718 ----
Karsten Hopp 6ad10d
  	parent = menu;
Karsten Hopp 6ad10d
  	name = next_name;
Karsten Hopp 6ad10d
  	vim_free(dname);
Karsten Hopp 6ad10d
+ 	dname = NULL;
Karsten Hopp 6ad10d
  	if (pri_tab[pri_idx + 1] != -1)
Karsten Hopp 6ad10d
  	    ++pri_idx;
Karsten Hopp 6ad10d
      }
Karsten Hopp 6ad10d
***************
Karsten Hopp 6ad10d
*** 793,798 ****
Karsten Hopp 6ad10d
--- 802,823 ----
Karsten Hopp 6ad10d
  erret:
Karsten Hopp 6ad10d
      vim_free(path_name);
Karsten Hopp 6ad10d
      vim_free(dname);
Karsten Hopp 6ad10d
+ 
Karsten Hopp 6ad10d
+     /* Delete any empty submenu we added before discovering the error.  Repeat
Karsten Hopp 6ad10d
+      * for higher levels. */
Karsten Hopp 6ad10d
+     while (parent != NULL && parent->children == NULL)
Karsten Hopp 6ad10d
+     {
Karsten Hopp 6ad10d
+ 	if (parent->parent == NULL)
Karsten Hopp 6ad10d
+ 	    menup = &root_menu;
Karsten Hopp 6ad10d
+ 	else
Karsten Hopp 6ad10d
+ 	    menup = &parent->parent->children;
Karsten Hopp 6ad10d
+ 	for ( ; *menup != NULL && *menup != parent; menup = &((*menup)->next))
Karsten Hopp 6ad10d
+ 	    ;
Karsten Hopp 6ad10d
+ 	if (*menup == NULL) /* safety check */
Karsten Hopp 6ad10d
+ 	    break;
Karsten Hopp 6ad10d
+ 	parent = parent->parent;
Karsten Hopp 6ad10d
+ 	free_menu(menup);
Karsten Hopp 6ad10d
+     }
Karsten Hopp 6ad10d
      return FAIL;
Karsten Hopp 6ad10d
  }
Karsten Hopp 6ad10d
  
Karsten Hopp 6ad10d
*** ../vim-7.0.053/src/version.c	Tue Aug 15 22:26:04 2006
Karsten Hopp 6ad10d
--- src/version.c	Wed Aug 16 15:53:39 2006
Karsten Hopp 6ad10d
***************
Karsten Hopp 6ad10d
*** 668,669 ****
Karsten Hopp 6ad10d
--- 668,671 ----
Karsten Hopp 6ad10d
  {   /* Add new patch number below this line */
Karsten Hopp 6ad10d
+ /**/
Karsten Hopp 6ad10d
+     54,
Karsten Hopp 6ad10d
  /**/
Karsten Hopp 6ad10d
Karsten Hopp 6ad10d
-- 
Karsten Hopp 6ad10d
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 6ad10d
156. You forget your friend's name but not her e-mail address.
Karsten Hopp 6ad10d
Karsten Hopp 6ad10d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 6ad10d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 6ad10d
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 6ad10d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///