To: vim-dev@vim.org Subject: Patch 6.1.402 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.402 Problem: When evaluating a function name with curly braces, an error is not handled consistently. Solution: Accept the result of an curly braces expression when an error was encountered. Skip evaluating an expression in curly braces when skipping. (Servatius Brandt) Files: src/eval.c *** ../vim61.401/src/eval.c Tue Mar 11 12:59:06 2003 --- src/eval.c Fri Mar 14 21:35:20 2003 *************** *** 318,324 **** static pos_T *var2fpos __ARGS((VAR varp, int lnum)); static int get_env_len __ARGS((char_u **arg)); static int get_id_len __ARGS((char_u **arg)); ! static int get_func_len __ARGS((char_u **arg, char_u **alias)); static char_u *find_name_end __ARGS((char_u *arg, char_u **expr_start, char_u **expr_end)); static int eval_isnamec __ARGS((int c)); static int find_vim_var __ARGS((char_u *name, int len)); --- 318,324 ---- static pos_T *var2fpos __ARGS((VAR varp, int lnum)); static int get_env_len __ARGS((char_u **arg)); static int get_id_len __ARGS((char_u **arg)); ! static int get_func_len __ARGS((char_u **arg, char_u **alias, int evaluate)); static char_u *find_name_end __ARGS((char_u *arg, char_u **expr_start, char_u **expr_end)); static int eval_isnamec __ARGS((int c)); static int find_vim_var __ARGS((char_u *name, int len)); *************** *** 1006,1012 **** int failed = FALSE; name = arg; ! len = get_func_len(&arg, &alias); if (len == 0) goto end; if (alias != NULL) --- 1006,1012 ---- int failed = FALSE; name = arg; ! len = get_func_len(&arg, &alias, !eap->skip); if (len == 0) goto end; if (alias != NULL) *************** *** 1995,2001 **** * Must be a variable or function name then. */ default: s = *arg; ! len = get_func_len(arg, &alias); if (alias != NULL) s = alias; --- 1995,2001 ---- * Must be a variable or function name then. */ default: s = *arg; ! len = get_func_len(arg, &alias, evaluate); if (alias != NULL) s = alias; *************** *** 6832,6840 **** * expanded name in an allocated string via 'alias' - caller must free. */ static int ! get_func_len(arg, alias) char_u **arg; char_u **alias; { int len; #ifdef FEAT_MAGIC_BRACES --- 6835,6844 ---- * expanded name in an allocated string via 'alias' - caller must free. */ static int ! get_func_len(arg, alias, evaluate) char_u **arg; char_u **alias; + int evaluate; { int len; #ifdef FEAT_MAGIC_BRACES *************** *** 6869,6874 **** --- 6873,6885 ---- { char_u *temp_string; + if (!evaluate) + { + len += (int)(p - *arg); + *arg = skipwhite(p); + return len; + } + /* * Include any etc in the expanded string: * Thus the -len here. *************** *** 7810,7815 **** --- 7821,7829 ---- char_u *theline; int j; int c; + #ifdef FEAT_MAGIC_BRACES + int saved_did_emsg; + #endif char_u *name = NULL; char_u *p; char_u *arg; *************** *** 7840,7845 **** --- 7854,7865 ---- name = trans_function_name(&p, eap->skip, FALSE); if (name == NULL && !eap->skip) return; + #ifdef FEAT_MAGIC_BRACES + /* An error in a function call during evaluation of an expression in magic + * braces should not cause the function not to be defined. */ + saved_did_emsg = did_emsg; + did_emsg = FALSE; + #endif /* * ":function func" with only function name: list function. *************** *** 8103,8108 **** --- 8123,8131 ---- fp->flags = flags; fp->calls = 0; fp->script_ID = current_SID; + #ifdef FEAT_MAGIC_BRACES + did_emsg |= saved_did_emsg; + #endif return; erret: *************** *** 8110,8115 **** --- 8133,8141 ---- ga_clear_strings(&newlines); erret_name: vim_free(name); + #ifdef FEAT_MAGIC_BRACES + did_emsg |= saved_did_emsg; + #endif } /* *** ../vim61.401/src/version.c Sat Mar 15 16:43:57 2003 --- src/version.c Sat Mar 15 16:46:14 2003 *************** *** 613,614 **** --- 613,616 ---- { /* Add new patch number below this line */ + /**/ + 402, /**/ -- From "know your smileys": !-| I-am-a-Cylon-Centurian-with-one-red-eye-bouncing-back-and-forth /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///