@@ -132,7 +132,9 @@ static int dbcs_char2cells(int c);
132132static int dbcs_ptr2cells_len (char_u * p , int size );
133133static int dbcs_ptr2char (char_u * p );
134134static int dbcs_head_off (char_u * base , char_u * p );
135+ #ifdef FEAT_EVAL
135136static int cw_value (int c );
137+ #endif
136138
137139/*
138140 * Lookup table to quickly get the length in bytes of a UTF-8 character from
@@ -1388,8 +1390,7 @@ utf_char2cells(int c)
13881390 {0x26ce , 0x26ce },
13891391 {0x26d4 , 0x26d4 },
13901392 {0x26ea , 0x26ea },
1391- {0x26f2 , 0x26f3 },
1392- {0x26f5 , 0x26f5 },
1393+ {0x26f2 , 0x26f5 },
13931394 {0x26fa , 0x26fa },
13941395 {0x26fd , 0x26fd },
13951396 {0x2705 , 0x2705 },
@@ -1490,6 +1491,21 @@ utf_char2cells(int c)
14901491 // based on http://unicode.org/emoji/charts/emoji-list.html
14911492 static struct interval emoji_wide [] =
14921493 {
1494+ {0x23ed , 0x23ef },
1495+ {0x23f1 , 0x23f2 },
1496+ {0x23f8 , 0x23fa },
1497+ {0x24c2 , 0x24c2 },
1498+ {0x261d , 0x261d },
1499+ {0x26c8 , 0x26c8 },
1500+ {0x26cf , 0x26cf },
1501+ {0x26d1 , 0x26d1 },
1502+ {0x26d3 , 0x26d3 },
1503+ {0x26e9 , 0x26e9 },
1504+ {0x26f0 , 0x26f1 },
1505+ {0x26f7 , 0x26f9 },
1506+ {0x270c , 0x270d },
1507+ {0x2934 , 0x2935 },
1508+ {0x1f170 , 0x1f189 },
14931509 {0x1f1e6 , 0x1f1ff },
14941510 {0x1f321 , 0x1f321 },
14951511 {0x1f324 , 0x1f32c },
@@ -1533,11 +1549,15 @@ utf_char2cells(int c)
15331549
15341550 if (c >= 0x100 )
15351551 {
1552+ #if defined(FEAT_EVAL ) || defined(USE_WCHAR_FUNCTIONS )
15361553 int n ;
1554+ #endif
15371555
1556+ #ifdef FEAT_EVAL
15381557 n = cw_value (c );
15391558 if (n != 0 )
15401559 return n ;
1560+ #endif
15411561
15421562#ifdef USE_WCHAR_FUNCTIONS
15431563 /*
@@ -2667,8 +2687,7 @@ static struct interval emoji_all[] =
26672687 {0x3299 , 0x3299 },
26682688 {0x1f004 , 0x1f004 },
26692689 {0x1f0cf , 0x1f0cf },
2670- {0x1f170 , 0x1f171 },
2671- {0x1f17e , 0x1f17f },
2690+ {0x1f170 , 0x1f189 },
26722691 {0x1f18e , 0x1f18e },
26732692 {0x1f191 , 0x1f19a },
26742693 {0x1f1e6 , 0x1f1ff },
@@ -2835,6 +2854,10 @@ utf_class_buf(int c, buf_T *buf)
28352854 return 1 ; // punctuation
28362855 }
28372856
2857+ // emoji
2858+ if (intable (emoji_all , sizeof (emoji_all ), c ))
2859+ return 3 ;
2860+
28382861 // binary search in table
28392862 while (top >= bot )
28402863 {
@@ -2847,10 +2870,6 @@ utf_class_buf(int c, buf_T *buf)
28472870 return (int )classes [mid ].class ;
28482871 }
28492872
2850- // emoji
2851- if (intable (emoji_all , sizeof (emoji_all ), c ))
2852- return 3 ;
2853-
28542873 // most other characters are "word" characters
28552874 return 2 ;
28562875}
@@ -5352,6 +5371,8 @@ string_convert_ext(
53525371 return retval ;
53535372}
53545373
5374+ #if defined(FEAT_EVAL ) || defined(PROTO )
5375+
53555376/*
53565377 * Table set by setcellwidths().
53575378 */
@@ -5525,3 +5546,17 @@ f_setcellwidths(typval_T *argvars, typval_T *rettv UNUSED)
55255546 cw_table = table ;
55265547 cw_table_size = l -> lv_len ;
55275548}
5549+
5550+ void
5551+ f_charclass (typval_T * argvars , typval_T * rettv UNUSED )
5552+ {
5553+ if (argvars [0 ].v_type != VAR_STRING
5554+ || argvars [0 ].vval .v_string == NULL
5555+ || * argvars [0 ].vval .v_string == NUL )
5556+ {
5557+ emsg (_ (e_stringreq ));
5558+ return ;
5559+ }
5560+ rettv -> vval .v_number = mb_get_class (argvars [0 ].vval .v_string );
5561+ }
5562+ #endif
0 commit comments