# HG changeset patch
# User ZyX <[email protected]>
# Date 1369572460 -14400
# Node ID 31b317a2cb89e8ad98bfa56ecbe2a668a7fd3a9a
# Parent a9cd5f321ccca75a8339146091ba461fae168b34
Don’t load autoload functions on vim.Function creation
diff -r a9cd5f321ccc -r 31b317a2cb89 src/eval.c
--- a/src/eval.c Sun May 26 16:47:10 2013 +0400
+++ b/src/eval.c Sun May 26 16:47:40 2013 +0400
@@ -810,6 +810,7 @@
# endif
prof_self_cmp __ARGS((const void *s1, const void *s2));
#endif
+static int script_autoload __ARGS((char_u *name, int reload));
static char_u *autoload_name __ARGS((char_u *name));
static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
static void func_free __ARGS((ufunc_T *fp));
@@ -829,10 +830,6 @@
static void sortFunctions __ARGS(());
#endif
-
-/* Character used as separated in autoload function/variable names. */
-#define AUTOLOAD_CHAR '#'
-
/*
* Initialize the global and v: variables.
*/
@@ -22187,7 +22184,7 @@
* If "name" has a package name try autoloading the script for it.
* Return TRUE if a package was loaded.
*/
- int
+ static int
script_autoload(name, reload)
char_u *name;
int reload; /* load script again when already loaded */
diff -r a9cd5f321ccc -r 31b317a2cb89 src/if_py_both.h
--- a/src/if_py_both.h Sun May 26 16:47:10 2013 +0400
+++ b/src/if_py_both.h Sun May 26 16:47:40 2013 +0400
@@ -2016,19 +2016,13 @@
func_ref(self->name);
}
else
- {
- self->name = get_expanded_name(name, TRUE);
- if (self->name == NULL)
+ if ((self->name = get_expanded_name(name,
+ vim_strchr(name, AUTOLOAD_CHAR) == NULL))
+ == NULL)
{
- if (script_autoload(name, TRUE) && !aborting())
- self->name = get_expanded_name(name, TRUE);
- if (self->name == NULL)
- {
- PyErr_SetString(PyExc_ValueError, _("function does not exist"));
- return NULL;
- }
+ PyErr_SetString(PyExc_ValueError, _("function does not exist"));
+ return NULL;
}
- }
return (PyObject *)(self);
}
diff -r a9cd5f321ccc -r 31b317a2cb89 src/proto/eval.pro
--- a/src/proto/eval.pro Sun May 26 16:47:10 2013 +0400
+++ b/src/proto/eval.pro Sun May 26 16:47:40 2013 +0400
@@ -132,5 +132,4 @@
void ex_oldfiles __ARGS((exarg_T *eap));
int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u
**bufp, int *fnamelen));
char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u
*flags));
-int script_autoload __ARGS((char_u *name, int reload));
/* vim: set ft=c : */
diff -r a9cd5f321ccc -r 31b317a2cb89 src/testdir/test86.ok
--- a/src/testdir/test86.ok Sun May 26 16:47:10 2013 +0400
+++ b/src/testdir/test86.ok Sun May 26 16:47:40 2013 +0400
@@ -889,7 +889,7 @@
>> FunctionConstructor
vim.Function("123"):(<type 'exceptions.ValueError'>, ValueError('unnamed
function does not exist',))
vim.Function("xxx_non_existent_function_xxx"):(<type 'exceptions.ValueError'>,
ValueError('function does not exist',))
-vim.Function("xxx#non#existent#function#xxx"):(<type 'exceptions.ValueError'>,
ValueError('function does not exist',))
+vim.Function("xxx#non#existent#function#xxx"):NOT FAILED
>> FunctionCall
>>> Testing StringToChars using f({%s : 1})
f({1 : 1}):(<type 'exceptions.TypeError'>, TypeError('object must be string',))
diff -r a9cd5f321ccc -r 31b317a2cb89 src/testdir/test87.ok
--- a/src/testdir/test87.ok Sun May 26 16:47:10 2013 +0400
+++ b/src/testdir/test87.ok Sun May 26 16:47:40 2013 +0400
@@ -878,7 +878,7 @@
>> FunctionConstructor
vim.Function("123"):(<class 'ValueError'>, ValueError('unnamed function does
not exist',))
vim.Function("xxx_non_existent_function_xxx"):(<class 'ValueError'>,
ValueError('function does not exist',))
-vim.Function("xxx#non#existent#function#xxx"):(<class 'ValueError'>,
ValueError('function does not exist',))
+vim.Function("xxx#non#existent#function#xxx"):NOT FAILED
>> FunctionCall
>>> Testing StringToChars using f({%s : 1})
f({1 : 1}):(<class 'TypeError'>, TypeError('object must be string',))
diff -r a9cd5f321ccc -r 31b317a2cb89 src/vim.h
--- a/src/vim.h Sun May 26 16:47:10 2013 +0400
+++ b/src/vim.h Sun May 26 16:47:40 2013 +0400
@@ -2243,4 +2243,7 @@
#define SREQ_WIN 1 /* Request window-local option */
#define SREQ_BUF 2 /* Request buffer-local option */
+/* Character used as separated in autoload function/variable names. */
+#define AUTOLOAD_CHAR '#'
+
#endif /* VIM__H */
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff -cr vim.a9cd5f321ccc/src/eval.c vim.31b317a2cb89/src/eval.c
*** vim.a9cd5f321ccc/src/eval.c 2013-05-26 16:49:02.280547842 +0400
--- vim.31b317a2cb89/src/eval.c 2013-05-26 16:49:02.310547450 +0400
***************
*** 810,815 ****
--- 810,816 ----
# endif
prof_self_cmp __ARGS((const void *s1, const void *s2));
#endif
+ static int script_autoload __ARGS((char_u *name, int reload));
static char_u *autoload_name __ARGS((char_u *name));
static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
static void func_free __ARGS((ufunc_T *fp));
***************
*** 829,838 ****
static void sortFunctions __ARGS(());
#endif
-
- /* Character used as separated in autoload function/variable names. */
- #define AUTOLOAD_CHAR '#'
-
/*
* Initialize the global and v: variables.
*/
--- 830,835 ----
***************
*** 22187,22193 ****
* If "name" has a package name try autoloading the script for it.
* Return TRUE if a package was loaded.
*/
! int
script_autoload(name, reload)
char_u *name;
int reload; /* load script again when already loaded */
--- 22184,22190 ----
* If "name" has a package name try autoloading the script for it.
* Return TRUE if a package was loaded.
*/
! static int
script_autoload(name, reload)
char_u *name;
int reload; /* load script again when already loaded */
diff -cr vim.a9cd5f321ccc/src/if_py_both.h vim.31b317a2cb89/src/if_py_both.h
*** vim.a9cd5f321ccc/src/if_py_both.h 2013-05-26 16:49:02.265548038 +0400
--- vim.31b317a2cb89/src/if_py_both.h 2013-05-26 16:49:02.291547698 +0400
***************
*** 2016,2034 ****
func_ref(self->name);
}
else
! {
! self->name = get_expanded_name(name, TRUE);
! if (self->name == NULL)
{
! if (script_autoload(name, TRUE) && !aborting())
! self->name = get_expanded_name(name, TRUE);
! if (self->name == NULL)
! {
! PyErr_SetString(PyExc_ValueError, _("function does not exist"));
! return NULL;
! }
}
- }
return (PyObject *)(self);
}
--- 2016,2028 ----
func_ref(self->name);
}
else
! if ((self->name = get_expanded_name(name,
! vim_strchr(name, AUTOLOAD_CHAR) == NULL))
! == NULL)
{
! PyErr_SetString(PyExc_ValueError, _("function does not exist"));
! return NULL;
}
return (PyObject *)(self);
}
diff -cr vim.a9cd5f321ccc/src/proto/eval.pro vim.31b317a2cb89/src/proto/eval.pro
*** vim.a9cd5f321ccc/src/proto/eval.pro 2013-05-26 16:49:02.267548012 +0400
--- vim.31b317a2cb89/src/proto/eval.pro 2013-05-26 16:49:02.294547659 +0400
***************
*** 132,136 ****
void ex_oldfiles __ARGS((exarg_T *eap));
int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen));
char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));
- int script_autoload __ARGS((char_u *name, int reload));
/* vim: set ft=c : */
--- 132,135 ----
diff -cr vim.a9cd5f321ccc/src/testdir/test86.ok vim.31b317a2cb89/src/testdir/test86.ok
*** vim.a9cd5f321ccc/src/testdir/test86.ok 2013-05-26 16:49:02.266548025 +0400
--- vim.31b317a2cb89/src/testdir/test86.ok 2013-05-26 16:49:02.293547672 +0400
***************
*** 889,895 ****
>> FunctionConstructor
vim.Function("123"):(<type 'exceptions.ValueError'>, ValueError('unnamed function does not exist',))
vim.Function("xxx_non_existent_function_xxx"):(<type 'exceptions.ValueError'>, ValueError('function does not exist',))
! vim.Function("xxx#non#existent#function#xxx"):(<type 'exceptions.ValueError'>, ValueError('function does not exist',))
>> FunctionCall
>>> Testing StringToChars using f({%s : 1})
f({1 : 1}):(<type 'exceptions.TypeError'>, TypeError('object must be string',))
--- 889,895 ----
>> FunctionConstructor
vim.Function("123"):(<type 'exceptions.ValueError'>, ValueError('unnamed function does not exist',))
vim.Function("xxx_non_existent_function_xxx"):(<type 'exceptions.ValueError'>, ValueError('function does not exist',))
! vim.Function("xxx#non#existent#function#xxx"):NOT FAILED
>> FunctionCall
>>> Testing StringToChars using f({%s : 1})
f({1 : 1}):(<type 'exceptions.TypeError'>, TypeError('object must be string',))
diff -cr vim.a9cd5f321ccc/src/testdir/test87.ok vim.31b317a2cb89/src/testdir/test87.ok
*** vim.a9cd5f321ccc/src/testdir/test87.ok 2013-05-26 16:49:02.260548103 +0400
--- vim.31b317a2cb89/src/testdir/test87.ok 2013-05-26 16:49:02.286547764 +0400
***************
*** 878,884 ****
>> FunctionConstructor
vim.Function("123"):(<class 'ValueError'>, ValueError('unnamed function does not exist',))
vim.Function("xxx_non_existent_function_xxx"):(<class 'ValueError'>, ValueError('function does not exist',))
! vim.Function("xxx#non#existent#function#xxx"):(<class 'ValueError'>, ValueError('function does not exist',))
>> FunctionCall
>>> Testing StringToChars using f({%s : 1})
f({1 : 1}):(<class 'TypeError'>, TypeError('object must be string',))
--- 878,884 ----
>> FunctionConstructor
vim.Function("123"):(<class 'ValueError'>, ValueError('unnamed function does not exist',))
vim.Function("xxx_non_existent_function_xxx"):(<class 'ValueError'>, ValueError('function does not exist',))
! vim.Function("xxx#non#existent#function#xxx"):NOT FAILED
>> FunctionCall
>>> Testing StringToChars using f({%s : 1})
f({1 : 1}):(<class 'TypeError'>, TypeError('object must be string',))
diff -cr vim.a9cd5f321ccc/src/vim.h vim.31b317a2cb89/src/vim.h
*** vim.a9cd5f321ccc/src/vim.h 2013-05-26 16:49:02.259548117 +0400
--- vim.31b317a2cb89/src/vim.h 2013-05-26 16:49:02.285547776 +0400
***************
*** 2243,2246 ****
--- 2243,2249 ----
#define SREQ_WIN 1 /* Request window-local option */
#define SREQ_BUF 2 /* Request buffer-local option */
+ /* Character used as separated in autoload function/variable names. */
+ #define AUTOLOAD_CHAR '#'
+
#endif /* VIM__H */