To: vim_dev@googlegroups.com Subject: Patch 8.2.4193 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4193 Problem: Cannot use an import in 'charconvert'. Solution: Set the script context when evaluating 'charconvert'. Also expand script-local functions in 'charconvert'. Files: src/evalvars.c, src/optionstr.c, src/testdir/test_vim9_import.vim *** ../vim-8.2.4192/src/evalvars.c 2022-01-23 13:43:43.819163952 +0000 --- src/evalvars.c 2022-01-23 14:03:57.335822896 +0000 *************** *** 369,385 **** --- 369,393 ---- char_u *fname_to) { int err = FALSE; + sctx_T saved_sctx = current_sctx; + sctx_T *ctx; set_vim_var_string(VV_CC_FROM, enc_from, -1); set_vim_var_string(VV_CC_TO, enc_to, -1); set_vim_var_string(VV_FNAME_IN, fname_from, -1); set_vim_var_string(VV_FNAME_OUT, fname_to, -1); + ctx = get_option_sctx("charconvert"); + if (ctx != NULL) + current_sctx = *ctx; + if (eval_to_bool(p_ccv, &err, NULL, FALSE)) err = TRUE; + set_vim_var_string(VV_CC_FROM, NULL, -1); set_vim_var_string(VV_CC_TO, NULL, -1); set_vim_var_string(VV_FNAME_IN, NULL, -1); set_vim_var_string(VV_FNAME_OUT, NULL, -1); + current_sctx = saved_sctx; if (err) return FAIL; *** ../vim-8.2.4192/src/optionstr.c 2022-01-08 12:41:12.208795550 +0000 --- src/optionstr.c 2022-01-23 14:06:16.997091427 +0000 *************** *** 2329,2336 **** # ifdef FEAT_POSTSCRIPT varp == &p_pexpr || # endif ! FALSE ! ) { char_u **p_opt = NULL; char_u *name; --- 2329,2335 ---- # ifdef FEAT_POSTSCRIPT varp == &p_pexpr || # endif ! varp == &p_ccv) { char_u **p_opt = NULL; char_u *name; *************** *** 2369,2374 **** --- 2368,2375 ---- if (varp == &p_pexpr) // 'printexpr' p_opt = &p_pexpr; # endif + if (varp == &p_ccv) // 'charconvert' + p_opt = &p_ccv; if (p_opt != NULL) { *** ../vim-8.2.4192/src/testdir/test_vim9_import.vim 2022-01-23 13:43:43.819163952 +0000 --- src/testdir/test_vim9_import.vim 2022-01-23 14:01:32.374653935 +0000 *************** *** 905,910 **** --- 905,941 ---- set printexpr= enddef + def Test_import_in_charconvert() + var lines =<< trim END + vim9script + export def MakeUpper(): bool + var data = readfile(v:fname_in) + map(data, 'toupper(v:val)') + writefile(data, v:fname_out) + return false # success + enddef + END + writefile(lines, 'Xconvert.vim') + + lines =<< trim END + vim9script + import './Xconvert.vim' as conv + set charconvert=conv.MakeUpper() + END + CheckScriptSuccess(lines) + + writefile(['one', 'two'], 'Xfile') + new Xfile + write ++enc=ucase Xfile1 + assert_equal(['ONE', 'TWO'], readfile('Xfile1')) + + delete('Xfile') + delete('Xfile1') + delete('Xconvert.vim') + bwipe! + set charconvert& + enddef + def Test_export_fails() CheckScriptFailure(['export var some = 123'], 'E1042:') CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') *** ../vim-8.2.4192/src/version.c 2022-01-23 13:43:43.823163878 +0000 --- src/version.c 2022-01-23 14:00:26.167945193 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4193, /**/ -- ARTHUR: No, hang on! Just answer the five questions ... GALAHAD: Three questions ... ARTHUR: Three questions ... And we shall watch ... and pray. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///