To: vim-dev@vim.org Subject: Patch 5.6.032 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.6.032 Problem: Functions with an argument that is a line number don't all accept ".", "$", etc. (Ralf Arens) Solution: Add get_art_lnum() and use it for setline(), line2byte() and synID(). Files: src/eval.c *** ../vim-5.6.31/src/eval.c Wed Jan 12 21:14:54 2000 --- src/eval.c Sat Feb 19 21:04:14 2000 *************** *** 143,148 **** --- 143,149 ---- static int get_env_var __ARGS((char_u **arg, VAR retvar, int evaluate)); static int find_internal_func __ARGS((char_u *name)); static int get_func_var __ARGS((char_u *name, int len, VAR retvar, char_u **arg, linenr_t firstline, linenr_t lastline, int *doesrange, int evaluate)); + static linenr_t get_arg_lnum __ARGS((VAR argvars, VAR retvar)); static void f_append __ARGS((VAR argvars, VAR retvar)); static void f_argc __ARGS((VAR argvars, VAR retvar)); static void f_argv __ARGS((VAR argvars, VAR retvar)); *************** *** 2133,2147 **** return ret; } - /********************************************* - * Implementation of the built-in functions - */ - /* ! * "append(lnum, string)" function */ ! static void ! f_append(argvars, retvar) VAR argvars; VAR retvar; { --- 2134,2144 ---- return ret; } /* ! * Get the lnum from the first argument. Also accepts ".", "$", etc. */ ! static linenr_t ! get_arg_lnum(argvars, retvar) VAR argvars; VAR retvar; { *************** *** 2154,2159 **** --- 2151,2174 ---- lnum = retvar->var_val.var_number; clear_var(retvar); } + return lnum; + } + + /********************************************* + * Implementation of the built-in functions + */ + + /* + * "append(lnum, string)" function + */ + static void + f_append(argvars, retvar) + VAR argvars; + VAR retvar; + { + long lnum; + + lnum = get_arg_lnum(argvars, retvar); retvar->var_val.var_number = 1; /* Default: Failed */ if (lnum >= 0 && lnum <= curbuf->b_ml.ml_line_count *************** *** 2747,2760 **** linenr_t lnum; char_u *p; ! lnum = get_var_number(&argvars[0]); ! if (lnum == 0) /* no valid number, try using line() */ ! { ! f_line(argvars, retvar); ! lnum = retvar->var_val.var_number; ! clear_var(retvar); ! } ! if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count) p = ml_get(lnum); else --- 2762,2768 ---- linenr_t lnum; char_u *p; ! lnum = get_arg_lnum(argvars, retvar); if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count) p = ml_get(lnum); else *************** *** 3390,3396 **** #else linenr_t lnum; ! lnum = get_var_number(&argvars[0]); if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1) retvar->var_val.var_number = -1; else --- 3398,3404 ---- #else linenr_t lnum; ! lnum = get_arg_lnum(argvars, retvar); if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1) retvar->var_val.var_number = -1; else *************** *** 3598,3604 **** linenr_t lnum; char_u *line; ! lnum = get_var_number(&argvars[0]); line = get_var_string(&argvars[1]); retvar->var_val.var_number = 1; /* FAIL is default */ --- 3606,3612 ---- linenr_t lnum; char_u *line; ! lnum = get_arg_lnum(argvars, retvar); line = get_var_string(&argvars[1]); retvar->var_val.var_number = 1; /* FAIL is default */ *************** *** 3722,3728 **** long col; int trans; ! line = get_var_number(&argvars[0]); col = get_var_number(&argvars[1]) - 1; trans = get_var_number(&argvars[2]); --- 3730,3736 ---- long col; int trans; ! line = get_arg_lnum(argvars, retvar); col = get_var_number(&argvars[1]) - 1; trans = get_var_number(&argvars[2]); *** ../vim-5.6.31/src/version.c Sat Mar 25 21:29:50 2000 --- src/version.c Sat Mar 25 21:31:20 2000 *************** *** 420,421 **** --- 420,423 ---- { /* Add new patch number below this line */ + /**/ + 32, /**/ -- An extraordinary TALL KNIGHT in all black (possibly John with Mike on his shoulders) walks out from the dark trees. He is extremely fierce and gruesome countenance. He walks towards KING ARTHUR and PATSY, who are wazzing like mad. (Salopian slang, meaning very scared. almost to the point of wetting oneself, e.g. before an important football match or prior to a postering. Salopian slang meaning a beating by the school praeposters. Sorry about the Salopian slant to this stage direction - Ed.) "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\ \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/