To: vim_dev@googlegroups.com Subject: Patch 9.0.0176 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0176 Problem: Checking character options is duplicated and incomplete. Solution: Move checking to check_chars_options(). (closes #10863) Files: src/mbyte.c, src/optionstr.c, src/screen.c, src/proto/screen.pro, src/testdir/test_options.vim *** ../vim-9.0.0175/src/mbyte.c 2022-07-04 21:03:33.107829279 +0100 --- src/mbyte.c 2022-08-09 12:44:58.016508945 +0100 *************** *** 5645,5675 **** cw_table = table; cw_table_size = l->lv_len; ! // Check that the new value does not conflict with 'fillchars' or ! // 'listchars'. ! if (set_chars_option(curwin, &p_fcs, FALSE) != NULL) ! error = e_conflicts_with_value_of_fillchars; ! else if (set_chars_option(curwin, &p_lcs, FALSE) != NULL) ! error = e_conflicts_with_value_of_listchars; ! else ! { ! tabpage_T *tp; ! win_T *wp; ! ! FOR_ALL_TAB_WINDOWS(tp, wp) ! { ! if (set_chars_option(wp, &wp->w_p_lcs, FALSE) != NULL) ! { ! error = e_conflicts_with_value_of_listchars; ! break; ! } ! if (set_chars_option(wp, &wp->w_p_fcs, FALSE) != NULL) ! { ! error = e_conflicts_with_value_of_fillchars; ! break; ! } ! } ! } if (error != NULL) { emsg(_(error)); --- 5645,5653 ---- cw_table = table; cw_table_size = l->lv_len; ! // Check that the new value does not conflict with 'listchars' or ! // 'fillchars'. ! error = check_chars_options(); if (error != NULL) { emsg(_(error)); *** ../vim-9.0.0175/src/optionstr.c 2022-07-27 18:26:00.149928207 +0100 --- src/optionstr.c 2022-08-09 12:44:58.020508941 +0100 *************** *** 866,889 **** { if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK) errmsg = e_invalid_argument; - else if (set_chars_option(curwin, &p_fcs, FALSE) != NULL) - errmsg = e_conflicts_with_value_of_fillchars; else ! { ! tabpage_T *tp; ! win_T *wp; ! ! FOR_ALL_TAB_WINDOWS(tp, wp) ! { ! if (set_chars_option(wp, &wp->w_p_lcs, FALSE) != NULL) ! { ! errmsg = e_conflicts_with_value_of_listchars; ! goto ambw_end; ! } ! } ! } ! ambw_end: ! {} } // 'background' --- 866,873 ---- { if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK) errmsg = e_invalid_argument; else ! errmsg = check_chars_options(); } // 'background' *** ../vim-9.0.0175/src/screen.c 2022-07-30 16:54:01.867698285 +0100 --- src/screen.c 2022-08-09 12:50:18.916228394 +0100 *************** *** 5155,5157 **** --- 5155,5182 ---- return NULL; // no error } + + /* + * Check all global and local values of 'listchars' and 'fillchars'. + * Return an untranslated error messages if any of them is invalid, NULL + * otherwise. + */ + char * + check_chars_options(void) + { + tabpage_T *tp; + win_T *wp; + + if (set_chars_option(curwin, &p_lcs, FALSE) != NULL) + return e_conflicts_with_value_of_listchars; + if (set_chars_option(curwin, &p_fcs, FALSE) != NULL) + return e_conflicts_with_value_of_fillchars; + FOR_ALL_TAB_WINDOWS(tp, wp) + { + if (set_chars_option(wp, &wp->w_p_lcs, FALSE) != NULL) + return e_conflicts_with_value_of_listchars; + if (set_chars_option(wp, &wp->w_p_fcs, FALSE) != NULL) + return e_conflicts_with_value_of_fillchars; + } + return NULL; + } *** ../vim-9.0.0175/src/proto/screen.pro 2022-07-04 21:03:33.103829294 +0100 --- src/proto/screen.pro 2022-08-09 12:50:22.012225521 +0100 *************** *** 56,59 **** --- 56,60 ---- int screen_screencol(void); int screen_screenrow(void); char *set_chars_option(win_T *wp, char_u **varp, int apply); + char *check_chars_options(void); /* vim: set ft=c : */ *** ../vim-9.0.0175/src/testdir/test_options.vim 2022-07-23 06:24:56.405106035 +0100 --- src/testdir/test_options.vim 2022-08-09 12:44:58.020508941 +0100 *************** *** 466,474 **** call assert_fails('set sessionoptions=curdir,sesdir', 'E474:') call assert_fails('set foldmarker={{{,', 'E474:') call assert_fails('set sessionoptions=sesdir,curdir', 'E474:') ! call assert_fails('set listchars=trail:· ambiwidth=double', 'E834:') set listchars& ! call assert_fails('set fillchars=stl:· ambiwidth=double', 'E835:') set fillchars& call assert_fails('set fileencoding=latin1,utf-8', 'E474:') set nomodifiable --- 466,482 ---- call assert_fails('set sessionoptions=curdir,sesdir', 'E474:') call assert_fails('set foldmarker={{{,', 'E474:') call assert_fails('set sessionoptions=sesdir,curdir', 'E474:') ! setlocal listchars=trail:· ! call assert_fails('set ambiwidth=double', 'E834:') ! setlocal listchars=trail:- ! setglobal listchars=trail:· ! call assert_fails('set ambiwidth=double', 'E834:') set listchars& ! setlocal fillchars=stl:· ! call assert_fails('set ambiwidth=double', 'E835:') ! setlocal fillchars=stl:- ! setglobal fillchars=stl:· ! call assert_fails('set ambiwidth=double', 'E835:') set fillchars& call assert_fails('set fileencoding=latin1,utf-8', 'E474:') set nomodifiable *** ../vim-9.0.0175/src/version.c 2022-08-09 12:24:51.200531696 +0100 --- src/version.c 2022-08-09 12:51:20.720170543 +0100 *************** *** 737,738 **** --- 737,740 ---- { /* Add new patch number below this line */ + /**/ + 176, /**/ -- Ten bugs in the hand is better than one as yet undetected. /// 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 ///