Patch 9.0.1223

2 views
Skip to first unread message

Bram Moolenaar

unread,
Jan 20, 2023, 11:01:32 AM1/20/23
to vim...@googlegroups.com

Patch 9.0.1223
Problem: Cannot use setcellwidths() below 0x100.
Solution: Also accept characters between 0x80 and 0x100. (Ken Takata,
closes #11834)
Files: runtime/doc/builtin.txt, src/errors.h, src/mbyte.c,
src/testdir/test_utf8.vim


*** ../vim-9.0.1222/runtime/doc/builtin.txt 2023-01-17 18:31:20.423373305 +0000
--- runtime/doc/builtin.txt 2023-01-20 15:51:52.114113095 +0000
***************
*** 7961,7967 ****
{low} and {high} can be the same, in which case this refers to
one character. Otherwise it is the range of characters from
{low} to {high} (inclusive). *E1111* *E1114*
! Only characters with value 0x100 and higher can be used.

{width} must be either 1 or 2, indicating the character width
in screen cells. *E1112*
--- 7966,7972 ----
{low} and {high} can be the same, in which case this refers to
one character. Otherwise it is the range of characters from
{low} to {high} (inclusive). *E1111* *E1114*
! Only characters with value 0x80 and higher can be used.

{width} must be either 1 or 2, indicating the character width
in screen cells. *E1112*
*** ../vim-9.0.1222/src/errors.h 2023-01-14 13:12:01.858485739 +0000
--- src/errors.h 2023-01-20 15:51:52.114113095 +0000
***************
*** 2841,2848 ****
INIT(= N_("E1112: List item %d cell width invalid"));
EXTERN char e_overlapping_ranges_for_nr[]
INIT(= N_("E1113: Overlapping ranges for 0x%lx"));
! EXTERN char e_only_values_of_0x100_and_higher_supported[]
! INIT(= N_("E1114: Only values of 0x100 and higher supported"));
EXTERN char e_assert_fails_fourth_argument[]
INIT(= N_("E1115: \"assert_fails()\" fourth argument must be a number"));
EXTERN char e_assert_fails_fifth_argument[]
--- 2841,2848 ----
INIT(= N_("E1112: List item %d cell width invalid"));
EXTERN char e_overlapping_ranges_for_nr[]
INIT(= N_("E1113: Overlapping ranges for 0x%lx"));
! EXTERN char e_only_values_of_0x80_and_higher_supported[]
! INIT(= N_("E1114: Only values of 0x80 and higher supported"));
EXTERN char e_assert_fails_fourth_argument[]
INIT(= N_("E1115: \"assert_fails()\" fourth argument must be a number"));
EXTERN char e_assert_fails_fifth_argument[]
*** ../vim-9.0.1222/src/mbyte.c 2023-01-18 12:45:26.635861937 +0000
--- src/mbyte.c 2023-01-20 15:58:25.598283275 +0000
***************
*** 1589,1607 ****
#endif
};

- if (c >= 0x100)
- {
- #if defined(FEAT_EVAL) || defined(USE_WCHAR_FUNCTIONS)
- int n;
- #endif
-
#ifdef FEAT_EVAL
! n = cw_value(c);
if (n != 0)
return n;
#endif

#ifdef USE_WCHAR_FUNCTIONS
/*
* Assume the library function wcwidth() works better than our own
* stuff. It should return 1 for ambiguous width chars!
--- 1589,1614 ----
#endif
};

#ifdef FEAT_EVAL
! // Use the value from setcellwidths() at 0x80 and higher, unless the
! // character is not printable.
! if (c >= 0x80 &&
! # ifdef USE_WCHAR_FUNCTIONS
! wcwidth(c) >= 1 &&
! # endif
! vim_isprintc(c))
! {
! int n = cw_value(c);
if (n != 0)
return n;
+ }
#endif

+ if (c >= 0x100)
+ {
#ifdef USE_WCHAR_FUNCTIONS
+ int n;
+
/*
* Assume the library function wcwidth() works better than our own
* stuff. It should return 1 for ambiguous width chars!
***************
*** 5661,5669 ****
if (i == 0)
{
n1 = lili->li_tv.vval.v_number;
! if (n1 < 0x100)
{
! emsg(_(e_only_values_of_0x100_and_higher_supported));
vim_free(ptrs);
return;
}
--- 5668,5676 ----
if (i == 0)
{
n1 = lili->li_tv.vval.v_number;
! if (n1 < 0x80)
{
! emsg(_(e_only_values_of_0x80_and_higher_supported));
vim_free(ptrs);
return;
}
*** ../vim-9.0.1222/src/testdir/test_utf8.vim 2023-01-17 18:31:20.427373305 +0000
--- src/testdir/test_utf8.vim 2023-01-20 15:51:52.130113102 +0000
***************
*** 167,172 ****
--- 167,205 ----
call assert_equal(2, strwidth("\u1339"))
call assert_equal(1, strwidth("\u133a"))

+ for aw in ['single', 'double']
+ exe 'set ambiwidth=' . aw
+ " Handle \u0080 to \u009F as control chars even on MS-Windows.
+ set isprint=@,161-255
+
+ call setcellwidths([])
+ " Control chars
+ call assert_equal(4, strwidth("\u0081"))
+ call assert_equal(6, strwidth("\uFEFF"))
+ " Ambiguous width chars
+ call assert_equal((aw == 'single') ? 1 : 2, strwidth("\u00A1"))
+ call assert_equal((aw == 'single') ? 1 : 2, strwidth("\u2010"))
+
+ call setcellwidths([[0x81, 0x81, 1], [0xA1, 0xA1, 1],
+ \ [0x2010, 0x2010, 1], [0xFEFF, 0xFEFF, 1]])
+ " Control chars
+ call assert_equal(4, strwidth("\u0081"))
+ call assert_equal(6, strwidth("\uFEFF"))
+ " Ambiguous width chars
+ call assert_equal(1, strwidth("\u00A1"))
+ call assert_equal(1, strwidth("\u2010"))
+
+ call setcellwidths([[0x81, 0x81, 2], [0xA1, 0xA1, 2],
+ \ [0x2010, 0x2010, 2], [0xFEFF, 0xFEFF, 2]])
+ " Control chars
+ call assert_equal(4, strwidth("\u0081"))
+ call assert_equal(6, strwidth("\uFEFF"))
+ " Ambiguous width chars
+ call assert_equal(2, strwidth("\u00A1"))
+ call assert_equal(2, strwidth("\u2010"))
+ endfor
+ set ambiwidth& isprint&
+
call setcellwidths([])

call assert_fails('call setcellwidths(1)', 'E1211:')
*** ../vim-9.0.1222/src/version.c 2023-01-19 17:49:53.857422165 +0000
--- src/version.c 2023-01-20 16:00:02.554322516 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1223,
/**/

--
"You know, it's at times like this when I'm trapped in a Vogon airlock with
a man from Betelgeuse and about to die of asphyxiation in deep space that I
really wish I'd listened to what my mother told me when I was young!"
"Why, what did she tell you?"
"I don't know, I didn't listen!"
-- Arthur Dent and Ford Prefect in Douglas Adams'
"The Hitchhiker's Guide to the Galaxy"

/// Bram Moolenaar -- Br...@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 ///
Reply all
Reply to author
Forward
0 new messages