0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

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.
This commit is contained in:
Bram Moolenaar
2022-03-30 21:12:27 +01:00
parent b4ad3b0dea
commit c0ceeeb839
15 changed files with 442 additions and 82 deletions

View File

@@ -1883,6 +1883,21 @@ fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error)
return fname;
}
/*
* 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".
*/
@@ -1890,17 +1905,12 @@ fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error)
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)