diff src/evalvars.c @ 20239:2135b4641680 v8.2.0675

patch 8.2.0675: Vim9: no support for closures Commit: https://github.com/vim/vim/commit/b84a381c75e50ca0e0a24cc3e152d0c70f8c2c7d Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 1 15:44:29 2020 +0200 patch 8.2.0675: Vim9: no support for closures Problem: Vim9: no support for closures. Solution: Do not re-use stack entries.
author Bram Moolenaar <Bram@vim.org>
date Fri, 01 May 2020 15:45:04 +0200
parents 5f9c2c7d3d73
children 74002d42dda0
line wrap: on
line diff
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -2495,19 +2495,19 @@ get_script_local_ht(void)
 
 /*
  * Look for "name[len]" in script-local variables.
- * Return -1 when not found.
+ * Return a non-NULL pointer when found, NULL when not found.
  */
-    int
+    void *
 lookup_scriptvar(char_u *name, size_t len, cctx_T *dummy UNUSED)
 {
     hashtab_T	*ht = get_script_local_ht();
     char_u	buffer[30];
     char_u	*p;
-    int		res;
+    void	*res;
     hashitem_T	*hi;
 
     if (ht == NULL)
-	return -1;
+	return NULL;
     if (len < sizeof(buffer) - 1)
     {
 	vim_strncpy(buffer, name, len);
@@ -2517,15 +2517,15 @@ lookup_scriptvar(char_u *name, size_t le
     {
 	p = vim_strnsave(name, (int)len);
 	if (p == NULL)
-	    return -1;
+	    return NULL;
     }
 
     hi = hash_find(ht, p);
-    res = HASHITEM_EMPTY(hi) ? -1 : 1;
+    res = HASHITEM_EMPTY(hi) ? NULL : hi;
 
     // if not script-local, then perhaps imported
-    if (res == -1 && find_imported(p, 0, NULL) != NULL)
-	res = 1;
+    if (res == NULL && find_imported(p, 0, NULL) != NULL)
+	res = p;
 
     if (p != buffer)
 	vim_free(p);