To: vim_dev@googlegroups.com Subject: Patch 9.0.0003 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0003 Problem: Functions are global while they could be local. Solution: Add "static". Add a few tests. (Yegappan Lakshmanan, closes #10612) Files: src/crypt.c, src/proto/crypt.pro, src/evalvars.c, src/proto/evalvars.pro, src/gui.c, src/proto/gui.pro, src/highlight.c, src/proto/highlight.pro, src/scriptfile.c, src/proto/scriptfile.pro, src/userfunc.c, src/proto/userfunc.pro, src/testdir/test_fold.vim, src/testdir/test_quickfix.vim, src/testdir/test_vim9_builtin.vim *** ../vim-9.0.0002/src/crypt.c 2022-05-09 19:07:03.000000000 +0100 --- src/crypt.c 2022-06-29 12:49:34.925082356 +0100 *************** *** 73,78 **** --- 73,82 ---- char_u *p2, int last); } cryptmethod_T; + static int crypt_sodium_init(cryptstate_T *state, char_u *key, char_u *salt, int salt_len, char_u *seed, int seed_len); + static long crypt_sodium_buffer_decode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last); + static long crypt_sodium_buffer_encode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last); + // index is method_nr of cryptstate_T, CRYPT_M_* static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = { // PK_Zip; very weak *************** *** 850,856 **** } } ! int crypt_sodium_init( cryptstate_T *state UNUSED, char_u *key UNUSED, --- 854,860 ---- } } ! static int crypt_sodium_init( cryptstate_T *state UNUSED, char_u *key UNUSED, *************** *** 1030,1036 **** * Encrypt "from[len]" into "to[len]". * "from" and "to" can be equal to encrypt in place. */ ! long crypt_sodium_buffer_encode( cryptstate_T *state UNUSED, char_u *from UNUSED, --- 1034,1040 ---- * Encrypt "from[len]" into "to[len]". * "from" and "to" can be equal to encrypt in place. */ ! static long crypt_sodium_buffer_encode( cryptstate_T *state UNUSED, char_u *from UNUSED, *************** *** 1080,1086 **** * Decrypt "from[len]" into "to[len]". * "from" and "to" can be equal to encrypt in place. */ ! long crypt_sodium_buffer_decode( cryptstate_T *state UNUSED, char_u *from UNUSED, --- 1084,1090 ---- * Decrypt "from[len]" into "to[len]". * "from" and "to" can be equal to encrypt in place. */ ! static long crypt_sodium_buffer_decode( cryptstate_T *state UNUSED, char_u *from UNUSED, *** ../vim-9.0.0002/src/proto/crypt.pro 2022-06-27 23:14:59.000000000 +0100 --- src/proto/crypt.pro 2022-06-29 12:51:59.948842664 +0100 *************** *** 24,32 **** void crypt_check_current_method(void); char_u *crypt_get_key(int store, int twice); void crypt_append_msg(buf_T *buf); - int crypt_sodium_init(cryptstate_T *state, char_u *key, char_u *salt, int salt_len, char_u *seed, int seed_len); - long crypt_sodium_buffer_encode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last); - long crypt_sodium_buffer_decode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last); int crypt_sodium_munlock(void *const addr, const size_t len); void crypt_sodium_randombytes_buf(void *const buf, const size_t size); /* vim: set ft=c : */ --- 24,29 ---- *** ../vim-9.0.0002/src/evalvars.c 2022-05-25 17:26:37.000000000 +0100 --- src/evalvars.c 2022-06-29 12:49:34.925082356 +0100 *************** *** 648,654 **** * Used for a heredoc assignment. * Returns NULL for an error. */ ! char_u * eval_all_expr_in_str(char_u *str) { garray_T ga; --- 648,654 ---- * Used for a heredoc assignment. * Returns NULL for an error. */ ! static char_u * eval_all_expr_in_str(char_u *str) { garray_T ga; *** ../vim-9.0.0002/src/proto/evalvars.pro 2022-06-27 23:15:03.000000000 +0100 --- src/proto/evalvars.pro 2022-06-29 12:52:05.884832987 +0100 *************** *** 14,20 **** void prepare_vimvar(int idx, typval_T *save_tv); void restore_vimvar(int idx, typval_T *save_tv); char_u *eval_one_expr_in_str(char_u *p, garray_T *gap, int evaluate); - char_u *eval_all_expr_in_str(char_u *str); list_T *heredoc_get(exarg_T *eap, char_u *cmd, int script_get, int vim9compile); void ex_var(exarg_T *eap); void ex_let(exarg_T *eap); --- 14,19 ---- *** ../vim-9.0.0002/src/gui.c 2022-06-16 18:45:30.000000000 +0100 --- src/gui.c 2022-06-29 12:49:34.929082349 +0100 *************** *** 32,37 **** --- 32,38 ---- static void gui_update_horiz_scrollbar(int); static void gui_set_fg_color(char_u *name); static void gui_set_bg_color(char_u *name); + static void init_gui_options(void); static win_T *xy2win(int x, int y, mouse_find_T popup); #ifdef GUI_MAY_FORK *************** *** 1395,1401 **** } #if defined(FEAT_MENU) || defined(PROTO) ! void gui_position_menu(void) { # if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) --- 1396,1402 ---- } #if defined(FEAT_MENU) || defined(PROTO) ! static void gui_position_menu(void) { # if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) *************** *** 4815,4821 **** /* * Option initializations that can only be done after opening the GUI window. */ ! void init_gui_options(void) { // Set the 'background' option according to the lightness of the --- 4816,4822 ---- /* * Option initializations that can only be done after opening the GUI window. */ ! static void init_gui_options(void) { // Set the 'background' option according to the lightness of the *** ../vim-9.0.0002/src/proto/gui.pro 2022-06-27 23:15:31.000000000 +0100 --- src/proto/gui.pro 2022-06-29 12:49:34.929082349 +0100 *************** *** 9,15 **** int gui_get_wide_font(void); void gui_set_ligatures(void); void gui_update_cursor(int force, int clear_selection); - void gui_position_menu(void); int gui_get_base_width(void); int gui_get_base_height(void); void gui_resize_shell(int pixel_width, int pixel_height); --- 9,14 ---- *************** *** 51,57 **** guicolor_T gui_get_color(char_u *name); int gui_get_lightness(guicolor_T pixel); char_u *gui_bg_default(void); - void init_gui_options(void); void gui_new_scrollbar_colors(void); void gui_focus_change(int in_focus); void gui_mouse_moved(int x, int y); --- 50,55 ---- *** ../vim-9.0.0002/src/highlight.c 2022-05-09 19:09:04.000000000 +0100 --- src/highlight.c 2022-06-29 12:49:34.929082349 +0100 *************** *** 566,572 **** * "boldp" will be set to TRUE or FALSE for a foreground color when using 8 * colors, otherwise it will be unchanged. */ ! int lookup_color(int idx, int foreground, int *boldp) { int color = color_numbers_16[idx]; --- 566,572 ---- * "boldp" will be set to TRUE or FALSE for a foreground color when using 8 * colors, otherwise it will be unchanged. */ ! static int lookup_color(int idx, int foreground, int *boldp) { int color = color_numbers_16[idx]; *** ../vim-9.0.0002/src/proto/highlight.pro 2022-06-27 23:15:08.000000000 +0100 --- src/proto/highlight.pro 2022-06-29 12:52:10.448825553 +0100 *************** *** 4,10 **** int highlight_link_id(int id); void init_highlight(int both, int reset); int load_colors(char_u *name); - int lookup_color(int idx, int foreground, int *boldp); void do_highlight(char_u *line, int forceit, int init); void free_highlight(void); void restore_cterm_colors(void); --- 4,9 ---- *** ../vim-9.0.0002/src/scriptfile.c 2022-05-17 17:45:59.000000000 +0100 --- src/scriptfile.c 2022-06-29 12:49:34.929082349 +0100 *************** *** 2346,2352 **** * Find the path of a script below the "autoload" directory. * Returns NULL if there is no "/autoload/" in the script name. */ ! char_u * script_name_after_autoload(scriptitem_T *si) { char_u *p = si->sn_name; --- 2346,2352 ---- * Find the path of a script below the "autoload" directory. * Returns NULL if there is no "/autoload/" in the script name. */ ! static char_u * script_name_after_autoload(scriptitem_T *si) { char_u *p = si->sn_name; *** ../vim-9.0.0002/src/proto/scriptfile.pro 2022-06-27 23:15:21.000000000 +0100 --- src/proto/scriptfile.pro 2022-06-29 12:49:34.929082349 +0100 *************** *** 40,46 **** void ex_finish(exarg_T *eap); void do_finish(exarg_T *eap, int reanimate); int source_finished(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie); - char_u *script_name_after_autoload(scriptitem_T *si); char_u *get_autoload_prefix(scriptitem_T *si); char_u *may_prefix_autoload(char_u *name); char_u *autoload_name(char_u *name); --- 40,45 ---- *** ../vim-9.0.0002/src/userfunc.c 2022-06-17 19:19:51.000000000 +0100 --- src/userfunc.c 2022-06-29 12:49:34.933082342 +0100 *************** *** 32,37 **** --- 32,38 ---- static void funccal_unref(funccall_T *fc, ufunc_T *fp, int force); static void func_clear(ufunc_T *fp, int force); static int func_free(ufunc_T *fp, int force); + static char_u *untrans_function_name(char_u *name); void func_init() *************** *** 4073,4079 **** * This can be used to first search for a script-local function and fall back * to the global function if not found. */ ! char_u * untrans_function_name(char_u *name) { char_u *p; --- 4074,4080 ---- * This can be used to first search for a script-local function and fall back * to the global function if not found. */ ! static char_u * untrans_function_name(char_u *name) { char_u *p; *** ../vim-9.0.0002/src/proto/userfunc.pro 2022-06-27 23:15:28.000000000 +0100 --- src/proto/userfunc.pro 2022-06-29 12:52:16.756815296 +0100 *************** *** 38,44 **** int call_func(char_u *funcname, int len, typval_T *rettv, int argcount_in, typval_T *argvars_in, funcexe_T *funcexe); char_u *printable_func_name(ufunc_T *fp); char_u *trans_function_name(char_u **pp, int *is_global, int skip, int flags, funcdict_T *fdp, partial_T **partial, type_T **type); - char_u *untrans_function_name(char_u *name); char_u *get_scriptlocal_funcname(char_u *funcname); char_u *alloc_printable_func_name(char_u *fname); char_u *save_function_name(char_u **name, int *is_global, int skip, int flags, funcdict_T *fudi); --- 38,43 ---- *** ../vim-9.0.0002/src/testdir/test_fold.vim 2022-05-23 15:32:42.000000000 +0100 --- src/testdir/test_fold.vim 2022-06-29 12:49:34.929082349 +0100 *************** *** 1476,1481 **** --- 1476,1483 ---- call assert_equal([0, 1, 1, 2, 2], range(1, 5)->map('foldlevel(v:val)')) call append(2, 'line 2.5') call assert_equal([0, 1, 0, 1, 2, 2], range(1, 6)->map('foldlevel(v:val)')) + 3d + call assert_equal([0, 1, 1, 2, 2], range(1, 5)->map('foldlevel(v:val)')) bw! endfunc *** ../vim-9.0.0002/src/testdir/test_quickfix.vim 2022-05-27 17:18:23.000000000 +0100 --- src/testdir/test_quickfix.vim 2022-06-29 12:49:34.929082349 +0100 *************** *** 3363,3370 **** cgetexpr ['Compiler: ' . repeat('a', 1015), 'File1:10:Hello World'] set efm=%DEntering\ directory\ %f,%f:%l:%m ! cgetexpr ['Entering directory ' . repeat('a', 1006), ! \ 'File1:10:Hello World'] set efm&vim endfunc --- 3363,3373 ---- cgetexpr ['Compiler: ' . repeat('a', 1015), 'File1:10:Hello World'] set efm=%DEntering\ directory\ %f,%f:%l:%m ! let lines =<< trim eval END ! Entering directory $"{repeat('a', 1006)}" ! File1:10:Hello World ! END ! cgetexpr lines set efm&vim endfunc *** ../vim-9.0.0002/src/testdir/test_vim9_builtin.vim 2022-05-26 12:07:07.000000000 +0100 --- src/testdir/test_vim9_builtin.vim 2022-06-29 12:49:34.929082349 +0100 *************** *** 3364,3369 **** --- 3364,3385 ---- v9.CheckDefAndScriptFailure(['searchdecl(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) v9.CheckDefAndScriptFailure(['searchdecl("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) v9.CheckDefAndScriptFailure(['searchdecl("a", true, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) + + # search for an empty string declaration + var lines: list =<< trim END + int var1; + + { + int var2; + var1 = 10; + } + END + new + setline(1, lines) + cursor(5, 4) + searchdecl('') + assert_equal([3, 1], [line('.'), col('.')]) + bw! enddef def Test_searchpair() *** ../vim-9.0.0002/src/version.c 2022-06-29 10:37:14.938302547 +0100 --- src/version.c 2022-06-29 12:53:14.484721876 +0100 *************** *** 737,738 **** --- 737,740 ---- { /* Add new patch number below this line */ + /**/ + 3, /**/ -- If Pacman had affected us as kids we'd be running around in dark rooms, munching pills and listening to repetitive music. -- Marcus Brigstocke /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///