diff src/userfunc.c @ 28249:4b322951ebac v8.2.4650

patch 8.2.4650: "import autoload" only works with using 'runtimepath' Commit: https://github.com/vim/vim/commit/c0ceeeb839b8c6bebd3a2abd1c07d40ec3c6edca Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 30 21:12:27 2022 +0100 patch 8.2.4650: "import autoload" only works with using 'runtimepath' Problem: "import autoload" only works with using 'runtimepath'. Solution: Also support a relative and absolute file name.
author Bram Moolenaar <Bram@vim.org>
date Wed, 30 Mar 2022 22:15:04 +0200
parents e5fcd1256ee3
children c446812efd60
line wrap: on
line diff
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -1884,23 +1884,33 @@ fname_trans_sid(char_u *name, char_u *fn
 }
 
 /*
+ * Concatenate the script ID and function name into  "<SNR>99_name".
+ * "buffer" must have size MAX_FUNC_NAME_LEN.
+ */
+    void
+func_name_with_sid(char_u *name, int sid, char_u *buffer)
+{
+    // A script-local function is stored as "<SNR>99_name".
+    buffer[0] = K_SPECIAL;
+    buffer[1] = KS_EXTRA;
+    buffer[2] = (int)KE_SNR;
+    vim_snprintf((char *)buffer + 3, MAX_FUNC_NAME_LEN - 3, "%ld_%s",
+							      (long)sid, name);
+}
+
+/*
  * Find a function "name" in script "sid".
  */
     static ufunc_T *
 find_func_with_sid(char_u *name, int sid)
 {
     hashitem_T	    *hi;
-    char_u	    buffer[200];
+    char_u	    buffer[MAX_FUNC_NAME_LEN];
 
     if (!SCRIPT_ID_VALID(sid))
 	return NULL;	// not in a script
 
-    // A script-local function is stored as "<SNR>99_name".
-    buffer[0] = K_SPECIAL;
-    buffer[1] = KS_EXTRA;
-    buffer[2] = (int)KE_SNR;
-    vim_snprintf((char *)buffer + 3, sizeof(buffer) - 3, "%ld_%s",
-							      (long)sid, name);
+    func_name_with_sid(name, sid, buffer);
     hi = hash_find(&func_hashtab, buffer);
     if (!HASHITEM_EMPTY(hi))
 	return HI2UF(hi);
@@ -1914,7 +1924,7 @@ find_func_with_sid(char_u *name, int sid
 find_func_with_prefix(char_u *name, int sid)
 {
     hashitem_T	    *hi;
-    char_u	    buffer[200];
+    char_u	    buffer[MAX_FUNC_NAME_LEN];
     scriptitem_T    *si;
 
     if (vim_strchr(name, AUTOLOAD_CHAR) != NULL)