Blob Blame History Raw
To: vim_dev@googlegroups.com
Subject: Patch 7.3.056
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.056
Problem:    "getline" argument in do_cmdline() shadows global.
Solution:   Rename the argument.
Files:	    src/ex_docmd.c


*** ../vim-7.3.055/src/ex_docmd.c	2010-11-10 18:59:50.000000000 +0100
--- src/ex_docmd.c	2010-11-16 11:24:40.000000000 +0100
***************
*** 733,739 ****
   * do_cmdline(): execute one Ex command line
   *
   * 1. Execute "cmdline" when it is not NULL.
!  *    If "cmdline" is NULL, or more lines are needed, getline() is used.
   * 2. Split up in parts separated with '|'.
   *
   * This function can be called recursively!
--- 733,739 ----
   * do_cmdline(): execute one Ex command line
   *
   * 1. Execute "cmdline" when it is not NULL.
!  *    If "cmdline" is NULL, or more lines are needed, fgetline() is used.
   * 2. Split up in parts separated with '|'.
   *
   * This function can be called recursively!
***************
*** 741,747 ****
   * flags:
   * DOCMD_VERBOSE  - The command will be included in the error message.
   * DOCMD_NOWAIT   - Don't call wait_return() and friends.
!  * DOCMD_REPEAT   - Repeat execution until getline() returns NULL.
   * DOCMD_KEYTYPED - Don't reset KeyTyped.
   * DOCMD_EXCRESET - Reset the exception environment (used for debugging).
   * DOCMD_KEEPLINE - Store first typed line (for repeating with ".").
--- 741,747 ----
   * flags:
   * DOCMD_VERBOSE  - The command will be included in the error message.
   * DOCMD_NOWAIT   - Don't call wait_return() and friends.
!  * DOCMD_REPEAT   - Repeat execution until fgetline() returns NULL.
   * DOCMD_KEYTYPED - Don't reset KeyTyped.
   * DOCMD_EXCRESET - Reset the exception environment (used for debugging).
   * DOCMD_KEEPLINE - Store first typed line (for repeating with ".").
***************
*** 749,763 ****
   * return FAIL if cmdline could not be executed, OK otherwise
   */
      int
! do_cmdline(cmdline, getline, cookie, flags)
      char_u	*cmdline;
!     char_u	*(*getline) __ARGS((int, void *, int));
!     void	*cookie;		/* argument for getline() */
      int		flags;
  {
      char_u	*next_cmdline;		/* next cmd to execute */
      char_u	*cmdline_copy = NULL;	/* copy of cmd line */
!     int		used_getline = FALSE;	/* used "getline" to obtain command */
      static int	recursive = 0;		/* recursive depth */
      int		msg_didout_before_start = 0;
      int		count = 0;		/* line number count */
--- 749,763 ----
   * return FAIL if cmdline could not be executed, OK otherwise
   */
      int
! do_cmdline(cmdline, fgetline, cookie, flags)
      char_u	*cmdline;
!     char_u	*(*fgetline) __ARGS((int, void *, int));
!     void	*cookie;		/* argument for fgetline() */
      int		flags;
  {
      char_u	*next_cmdline;		/* next cmd to execute */
      char_u	*cmdline_copy = NULL;	/* copy of cmd line */
!     int		used_getline = FALSE;	/* used "fgetline" to obtain command */
      static int	recursive = 0;		/* recursive depth */
      int		msg_didout_before_start = 0;
      int		count = 0;		/* line number count */
***************
*** 775,788 ****
      struct msglist	**saved_msg_list = NULL;
      struct msglist	*private_msg_list;
  
!     /* "getline" and "cookie" passed to do_one_cmd() */
      char_u	*(*cmd_getline) __ARGS((int, void *, int));
      void	*cmd_cookie;
      struct loop_cookie cmd_loop_cookie;
      void	*real_cookie;
      int		getline_is_func;
  #else
! # define cmd_getline getline
  # define cmd_cookie cookie
  #endif
      static int	call_depth = 0;		/* recursiveness */
--- 775,788 ----
      struct msglist	**saved_msg_list = NULL;
      struct msglist	*private_msg_list;
  
!     /* "fgetline" and "cookie" passed to do_one_cmd() */
      char_u	*(*cmd_getline) __ARGS((int, void *, int));
      void	*cmd_cookie;
      struct loop_cookie cmd_loop_cookie;
      void	*real_cookie;
      int		getline_is_func;
  #else
! # define cmd_getline fgetline
  # define cmd_cookie cookie
  #endif
      static int	call_depth = 0;		/* recursiveness */
***************
*** 822,831 ****
      cstack.cs_lflags = 0;
      ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10);
  
!     real_cookie = getline_cookie(getline, cookie);
  
      /* Inside a function use a higher nesting level. */
!     getline_is_func = getline_equal(getline, cookie, get_func_line);
      if (getline_is_func && ex_nesting_level == func_level(real_cookie))
  	++ex_nesting_level;
  
--- 822,831 ----
      cstack.cs_lflags = 0;
      ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10);
  
!     real_cookie = getline_cookie(fgetline, cookie);
  
      /* Inside a function use a higher nesting level. */
!     getline_is_func = getline_equal(fgetline, cookie, get_func_line);
      if (getline_is_func && ex_nesting_level == func_level(real_cookie))
  	++ex_nesting_level;
  
***************
*** 837,843 ****
  	breakpoint = func_breakpoint(real_cookie);
  	dbg_tick = func_dbg_tick(real_cookie);
      }
!     else if (getline_equal(getline, cookie, getsourceline))
      {
  	fname = sourcing_name;
  	breakpoint = source_breakpoint(real_cookie);
--- 837,843 ----
  	breakpoint = func_breakpoint(real_cookie);
  	dbg_tick = func_dbg_tick(real_cookie);
      }
!     else if (getline_equal(fgetline, cookie, getsourceline))
      {
  	fname = sourcing_name;
  	breakpoint = source_breakpoint(real_cookie);
***************
*** 881,887 ****
       * KeyTyped is only set when calling vgetc().  Reset it here when not
       * calling vgetc() (sourced command lines).
       */
!     if (!(flags & DOCMD_KEYTYPED) && !getline_equal(getline, cookie, getexline))
  	KeyTyped = FALSE;
  
      /*
--- 881,888 ----
       * KeyTyped is only set when calling vgetc().  Reset it here when not
       * calling vgetc() (sourced command lines).
       */
!     if (!(flags & DOCMD_KEYTYPED)
! 			       && !getline_equal(fgetline, cookie, getexline))
  	KeyTyped = FALSE;
  
      /*
***************
*** 894,900 ****
      do
      {
  #ifdef FEAT_EVAL
! 	getline_is_func = getline_equal(getline, cookie, get_func_line);
  #endif
  
  	/* stop skipping cmds for an error msg after all endif/while/for */
--- 895,901 ----
      do
      {
  #ifdef FEAT_EVAL
! 	getline_is_func = getline_equal(fgetline, cookie, get_func_line);
  #endif
  
  	/* stop skipping cmds for an error msg after all endif/while/for */
***************
*** 909,915 ****
  
  	/*
  	 * 1. If repeating a line in a loop, get a line from lines_ga.
! 	 * 2. If no line given: Get an allocated line with getline().
  	 * 3. If a line is given: Make a copy, so we can mess with it.
  	 */
  
--- 910,916 ----
  
  	/*
  	 * 1. If repeating a line in a loop, get a line from lines_ga.
! 	 * 2. If no line given: Get an allocated line with fgetline().
  	 * 3. If a line is given: Make a copy, so we can mess with it.
  	 */
  
***************
*** 938,949 ****
  	    }
  #ifdef FEAT_PROFILE
  	    else if (do_profiling == PROF_YES
! 			     && getline_equal(getline, cookie, getsourceline))
  		script_line_end();
  #endif
  
  	    /* Check if a sourced file hit a ":finish" command. */
! 	    if (source_finished(getline, cookie))
  	    {
  		retval = FAIL;
  		break;
--- 939,950 ----
  	    }
  #ifdef FEAT_PROFILE
  	    else if (do_profiling == PROF_YES
! 			    && getline_equal(fgetline, cookie, getsourceline))
  		script_line_end();
  #endif
  
  	    /* Check if a sourced file hit a ":finish" command. */
! 	    if (source_finished(fgetline, cookie))
  	    {
  		retval = FAIL;
  		break;
***************
*** 954,960 ****
  						   && *dbg_tick != debug_tick)
  	    {
  		*breakpoint = dbg_find_breakpoint(
! 				getline_equal(getline, cookie, getsourceline),
  							fname, sourcing_lnum);
  		*dbg_tick = debug_tick;
  	    }
--- 955,961 ----
  						   && *dbg_tick != debug_tick)
  	    {
  		*breakpoint = dbg_find_breakpoint(
! 				getline_equal(fgetline, cookie, getsourceline),
  							fname, sourcing_lnum);
  		*dbg_tick = debug_tick;
  	    }
***************
*** 969,975 ****
  		dbg_breakpoint(fname, sourcing_lnum);
  		/* Find next breakpoint. */
  		*breakpoint = dbg_find_breakpoint(
! 				getline_equal(getline, cookie, getsourceline),
  							fname, sourcing_lnum);
  		*dbg_tick = debug_tick;
  	    }
--- 970,976 ----
  		dbg_breakpoint(fname, sourcing_lnum);
  		/* Find next breakpoint. */
  		*breakpoint = dbg_find_breakpoint(
! 			       getline_equal(fgetline, cookie, getsourceline),
  							fname, sourcing_lnum);
  		*dbg_tick = debug_tick;
  	    }
***************
*** 978,984 ****
  	    {
  		if (getline_is_func)
  		    func_line_start(real_cookie);
! 		else if (getline_equal(getline, cookie, getsourceline))
  		    script_line_start();
  	    }
  # endif
--- 979,985 ----
  	    {
  		if (getline_is_func)
  		    func_line_start(real_cookie);
! 		else if (getline_equal(fgetline, cookie, getsourceline))
  		    script_line_start();
  	    }
  # endif
***************
*** 987,993 ****
  	if (cstack.cs_looplevel > 0)
  	{
  	    /* Inside a while/for loop we need to store the lines and use them
! 	     * again.  Pass a different "getline" function to do_one_cmd()
  	     * below, so that it stores lines in or reads them from
  	     * "lines_ga".  Makes it possible to define a function inside a
  	     * while/for loop. */
--- 988,994 ----
  	if (cstack.cs_looplevel > 0)
  	{
  	    /* Inside a while/for loop we need to store the lines and use them
! 	     * again.  Pass a different "fgetline" function to do_one_cmd()
  	     * below, so that it stores lines in or reads them from
  	     * "lines_ga".  Makes it possible to define a function inside a
  	     * while/for loop. */
***************
*** 995,1021 ****
  	    cmd_cookie = (void *)&cmd_loop_cookie;
  	    cmd_loop_cookie.lines_gap = &lines_ga;
  	    cmd_loop_cookie.current_line = current_line;
! 	    cmd_loop_cookie.getline = getline;
  	    cmd_loop_cookie.cookie = cookie;
  	    cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len);
  	}
  	else
  	{
! 	    cmd_getline = getline;
  	    cmd_cookie = cookie;
  	}
  #endif
  
! 	/* 2. If no line given, get an allocated line with getline(). */
  	if (next_cmdline == NULL)
  	{
  	    /*
  	     * Need to set msg_didout for the first line after an ":if",
  	     * otherwise the ":if" will be overwritten.
  	     */
! 	    if (count == 1 && getline_equal(getline, cookie, getexline))
  		msg_didout = TRUE;
! 	    if (getline == NULL || (next_cmdline = getline(':', cookie,
  #ifdef FEAT_EVAL
  		    cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2
  #else
--- 996,1022 ----
  	    cmd_cookie = (void *)&cmd_loop_cookie;
  	    cmd_loop_cookie.lines_gap = &lines_ga;
  	    cmd_loop_cookie.current_line = current_line;
! 	    cmd_loop_cookie.getline = fgetline;
  	    cmd_loop_cookie.cookie = cookie;
  	    cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len);
  	}
  	else
  	{
! 	    cmd_getline = fgetline;
  	    cmd_cookie = cookie;
  	}
  #endif
  
! 	/* 2. If no line given, get an allocated line with fgetline(). */
  	if (next_cmdline == NULL)
  	{
  	    /*
  	     * Need to set msg_didout for the first line after an ":if",
  	     * otherwise the ":if" will be overwritten.
  	     */
! 	    if (count == 1 && getline_equal(fgetline, cookie, getexline))
  		msg_didout = TRUE;
! 	    if (fgetline == NULL || (next_cmdline = fgetline(':', cookie,
  #ifdef FEAT_EVAL
  		    cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2
  #else
***************
*** 1142,1148 ****
  	     * If the command was typed, remember it for the ':' register.
  	     * Do this AFTER executing the command to make :@: work.
  	     */
! 	    if (getline_equal(getline, cookie, getexline)
  						  && new_last_cmdline != NULL)
  	    {
  		vim_free(last_cmdline);
--- 1143,1149 ----
  	     * If the command was typed, remember it for the ':' register.
  	     * Do this AFTER executing the command to make :@: work.
  	     */
! 	    if (getline_equal(fgetline, cookie, getexline)
  						  && new_last_cmdline != NULL)
  	    {
  		vim_free(last_cmdline);
***************
*** 1163,1169 ****
  #ifdef FEAT_EVAL
  	/* reset did_emsg for a function that is not aborted by an error */
  	if (did_emsg && !force_abort
! 		&& getline_equal(getline, cookie, get_func_line)
  					      && !func_has_abort(real_cookie))
  	    did_emsg = FALSE;
  
--- 1164,1170 ----
  #ifdef FEAT_EVAL
  	/* reset did_emsg for a function that is not aborted by an error */
  	if (did_emsg && !force_abort
! 		&& getline_equal(fgetline, cookie, get_func_line)
  					      && !func_has_abort(real_cookie))
  	    did_emsg = FALSE;
  
***************
*** 1202,1208 ****
  		    if (breakpoint != NULL)
  		    {
  			*breakpoint = dbg_find_breakpoint(
! 				getline_equal(getline, cookie, getsourceline),
  									fname,
  			   ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1);
  			*dbg_tick = debug_tick;
--- 1203,1209 ----
  		    if (breakpoint != NULL)
  		    {
  			*breakpoint = dbg_find_breakpoint(
! 			       getline_equal(fgetline, cookie, getsourceline),
  									fname,
  			   ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1);
  			*dbg_tick = debug_tick;
***************
*** 1296,1303 ****
  #endif
  	    )
  	    && !(did_emsg && used_getline
! 			  && (getline_equal(getline, cookie, getexmodeline)
! 				|| getline_equal(getline, cookie, getexline)))
  	    && (next_cmdline != NULL
  #ifdef FEAT_EVAL
  			|| cstack.cs_idx >= 0
--- 1297,1304 ----
  #endif
  	    )
  	    && !(did_emsg && used_getline
! 			    && (getline_equal(fgetline, cookie, getexmodeline)
! 			       || getline_equal(fgetline, cookie, getexline)))
  	    && (next_cmdline != NULL
  #ifdef FEAT_EVAL
  			|| cstack.cs_idx >= 0
***************
*** 1316,1324 ****
  	 * unclosed conditional.
  	 */
  	if (!got_int && !did_throw
! 		&& ((getline_equal(getline, cookie, getsourceline)
! 			&& !source_finished(getline, cookie))
! 		    || (getline_equal(getline, cookie, get_func_line)
  					    && !func_has_ended(real_cookie))))
  	{
  	    if (cstack.cs_flags[cstack.cs_idx] & CSF_TRY)
--- 1317,1325 ----
  	 * unclosed conditional.
  	 */
  	if (!got_int && !did_throw
! 		&& ((getline_equal(fgetline, cookie, getsourceline)
! 			&& !source_finished(fgetline, cookie))
! 		    || (getline_equal(fgetline, cookie, get_func_line)
  					    && !func_has_ended(real_cookie))))
  	{
  	    if (cstack.cs_flags[cstack.cs_idx] & CSF_TRY)
***************
*** 1354,1360 ****
      /* If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory
       * lack was reported above and the error message is to be converted to an
       * exception, do this now after rewinding the cstack. */
!     do_errthrow(&cstack, getline_equal(getline, cookie, get_func_line)
  				  ? (char_u *)"endfunction" : (char_u *)NULL);
  
      if (trylevel == 0)
--- 1355,1361 ----
      /* If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory
       * lack was reported above and the error message is to be converted to an
       * exception, do this now after rewinding the cstack. */
!     do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line)
  				  ? (char_u *)"endfunction" : (char_u *)NULL);
  
      if (trylevel == 0)
***************
*** 1449,1457 ****
       */
      if (did_throw)
  	need_rethrow = TRUE;
!     if ((getline_equal(getline, cookie, getsourceline)
  		&& ex_nesting_level > source_level(real_cookie))
! 	    || (getline_equal(getline, cookie, get_func_line)
  		&& ex_nesting_level > func_level(real_cookie) + 1))
      {
  	if (!did_throw)
--- 1450,1458 ----
       */
      if (did_throw)
  	need_rethrow = TRUE;
!     if ((getline_equal(fgetline, cookie, getsourceline)
  		&& ex_nesting_level > source_level(real_cookie))
! 	    || (getline_equal(fgetline, cookie, get_func_line)
  		&& ex_nesting_level > func_level(real_cookie) + 1))
      {
  	if (!did_throw)
***************
*** 1460,1475 ****
      else
      {
  	/* When leaving a function, reduce nesting level. */
! 	if (getline_equal(getline, cookie, get_func_line))
  	    --ex_nesting_level;
  	/*
  	 * Go to debug mode when returning from a function in which we are
  	 * single-stepping.
  	 */
! 	if ((getline_equal(getline, cookie, getsourceline)
! 		    || getline_equal(getline, cookie, get_func_line))
  		&& ex_nesting_level + 1 <= debug_break_level)
! 	    do_debug(getline_equal(getline, cookie, getsourceline)
  		    ? (char_u *)_("End of sourced file")
  		    : (char_u *)_("End of function"));
      }
--- 1461,1476 ----
      else
      {
  	/* When leaving a function, reduce nesting level. */
! 	if (getline_equal(fgetline, cookie, get_func_line))
  	    --ex_nesting_level;
  	/*
  	 * Go to debug mode when returning from a function in which we are
  	 * single-stepping.
  	 */
! 	if ((getline_equal(fgetline, cookie, getsourceline)
! 		    || getline_equal(fgetline, cookie, get_func_line))
  		&& ex_nesting_level + 1 <= debug_break_level)
! 	    do_debug(getline_equal(fgetline, cookie, getsourceline)
  		    ? (char_u *)_("End of sourced file")
  		    : (char_u *)_("End of function"));
      }
*** ../vim-7.3.055/src/version.c	2010-11-16 11:28:33.000000000 +0100
--- src/version.c	2010-11-16 11:27:09.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     56,
  /**/

-- 
Lawmakers made it obligatory for everybody to take at least one bath
each week -- on Saturday night.
		[real standing law in Vermont, United States of America]

 /// Bram Moolenaar -- Bram@Moolenaar.net -- 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    ///