diff src/eval.c @ 7135:9d4986f52df8 v7.4.879

commit https://github.com/vim/vim/commit/1d6328ca00fc6cfe37b1f5e038ec23f443258886 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 25 17:37:16 2015 +0200 patch 7.4.879 Problem: Can't see line numbers in nested function calls. Solution: Add line number to the file name. (Alberto Fanjul)
author Christian Brabandt <cb@256bit.org>
date Fri, 25 Sep 2015 17:45:04 +0200
parents 5fc5c5bf2233
children a01294e1c02f
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -23817,6 +23817,7 @@ call_user_func(fp, argcount, argvars, re
     int		ai;
     char_u	numbuf[NUMBUFLEN];
     char_u	*name;
+    size_t	len;
 #ifdef FEAT_PROFILE
     proftime_T	wait_start;
     proftime_T	call_start;
@@ -23948,13 +23949,16 @@ call_user_func(fp, argcount, argvars, re
     save_sourcing_name = sourcing_name;
     save_sourcing_lnum = sourcing_lnum;
     sourcing_lnum = 1;
-    sourcing_name = alloc((unsigned)((save_sourcing_name == NULL ? 0
-		: STRLEN(save_sourcing_name)) + STRLEN(fp->uf_name) + 13));
+    /* need space for function name + ("function " + 3) or "[number]" */
+    len = (save_sourcing_name == NULL ? 0 : STRLEN(save_sourcing_name))
+						   + STRLEN(fp->uf_name) + 20;
+    sourcing_name = alloc((unsigned)len);
     if (sourcing_name != NULL)
     {
 	if (save_sourcing_name != NULL
 			  && STRNCMP(save_sourcing_name, "function ", 9) == 0)
-	    sprintf((char *)sourcing_name, "%s..", save_sourcing_name);
+	    sprintf((char *)sourcing_name, "%s[%d]..",
+				 save_sourcing_name, (int)save_sourcing_lnum);
 	else
 	    STRCPY(sourcing_name, "function ");
 	cat_func_name(sourcing_name + STRLEN(sourcing_name), fp);