|
Karsten Hopp |
d4be56 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
d4be56 |
Subject: Patch 7.4.057
|
|
Karsten Hopp |
d4be56 |
Fcc: outbox
|
|
Karsten Hopp |
d4be56 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
d4be56 |
Mime-Version: 1.0
|
|
Karsten Hopp |
d4be56 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
d4be56 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
d4be56 |
------------
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
Patch 7.4.057
|
|
Karsten Hopp |
d4be56 |
Problem: byteidx() does not work for composing characters.
|
|
Karsten Hopp |
d4be56 |
Solution: Add byteidxcomp().
|
|
Karsten Hopp |
d4be56 |
Files: src/eval.c, src/testdir/test69.in, src/testdir/test69.ok,
|
|
Karsten Hopp |
d4be56 |
runtime/doc/eval.txt
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
*** ../vim-7.4.056/src/eval.c 2013-10-02 16:46:23.000000000 +0200
|
|
Karsten Hopp |
d4be56 |
--- src/eval.c 2013-11-02 22:30:08.000000000 +0100
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 474,480 ****
|
|
Karsten Hopp |
d4be56 |
--- 474,482 ----
|
|
Karsten Hopp |
d4be56 |
static void f_bufnr __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
d4be56 |
static void f_bufwinnr __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
d4be56 |
static void f_byte2line __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
d4be56 |
+ static void byteidx __ARGS((typval_T *argvars, typval_T *rettv, int comp));
|
|
Karsten Hopp |
d4be56 |
static void f_byteidx __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
d4be56 |
+ static void f_byteidxcomp __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
d4be56 |
static void f_call __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
d4be56 |
#ifdef FEAT_FLOAT
|
|
Karsten Hopp |
d4be56 |
static void f_ceil __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 7861,7866 ****
|
|
Karsten Hopp |
d4be56 |
--- 7863,7869 ----
|
|
Karsten Hopp |
d4be56 |
{"bufwinnr", 1, 1, f_bufwinnr},
|
|
Karsten Hopp |
d4be56 |
{"byte2line", 1, 1, f_byte2line},
|
|
Karsten Hopp |
d4be56 |
{"byteidx", 2, 2, f_byteidx},
|
|
Karsten Hopp |
d4be56 |
+ {"byteidxcomp", 2, 2, f_byteidxcomp},
|
|
Karsten Hopp |
d4be56 |
{"call", 2, 3, f_call},
|
|
Karsten Hopp |
d4be56 |
#ifdef FEAT_FLOAT
|
|
Karsten Hopp |
d4be56 |
{"ceil", 1, 1, f_ceil},
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 9177,9189 ****
|
|
Karsten Hopp |
d4be56 |
#endif
|
|
Karsten Hopp |
d4be56 |
}
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
- /*
|
|
Karsten Hopp |
d4be56 |
- * "byteidx()" function
|
|
Karsten Hopp |
d4be56 |
- */
|
|
Karsten Hopp |
d4be56 |
static void
|
|
Karsten Hopp |
d4be56 |
! f_byteidx(argvars, rettv)
|
|
Karsten Hopp |
d4be56 |
typval_T *argvars;
|
|
Karsten Hopp |
d4be56 |
typval_T *rettv;
|
|
Karsten Hopp |
d4be56 |
{
|
|
Karsten Hopp |
d4be56 |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
d4be56 |
char_u *t;
|
|
Karsten Hopp |
d4be56 |
--- 9180,9190 ----
|
|
Karsten Hopp |
d4be56 |
#endif
|
|
Karsten Hopp |
d4be56 |
}
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
static void
|
|
Karsten Hopp |
d4be56 |
! byteidx(argvars, rettv, comp)
|
|
Karsten Hopp |
d4be56 |
typval_T *argvars;
|
|
Karsten Hopp |
d4be56 |
typval_T *rettv;
|
|
Karsten Hopp |
d4be56 |
+ int comp;
|
|
Karsten Hopp |
d4be56 |
{
|
|
Karsten Hopp |
d4be56 |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
d4be56 |
char_u *t;
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 9203,9209 ****
|
|
Karsten Hopp |
d4be56 |
{
|
|
Karsten Hopp |
d4be56 |
if (*t == NUL) /* EOL reached */
|
|
Karsten Hopp |
d4be56 |
return;
|
|
Karsten Hopp |
d4be56 |
! t += (*mb_ptr2len)(t);
|
|
Karsten Hopp |
d4be56 |
}
|
|
Karsten Hopp |
d4be56 |
rettv->vval.v_number = (varnumber_T)(t - str);
|
|
Karsten Hopp |
d4be56 |
#else
|
|
Karsten Hopp |
d4be56 |
--- 9204,9213 ----
|
|
Karsten Hopp |
d4be56 |
{
|
|
Karsten Hopp |
d4be56 |
if (*t == NUL) /* EOL reached */
|
|
Karsten Hopp |
d4be56 |
return;
|
|
Karsten Hopp |
d4be56 |
! if (enc_utf8 && comp)
|
|
Karsten Hopp |
d4be56 |
! t += utf_ptr2len(t);
|
|
Karsten Hopp |
d4be56 |
! else
|
|
Karsten Hopp |
d4be56 |
! t += (*mb_ptr2len)(t);
|
|
Karsten Hopp |
d4be56 |
}
|
|
Karsten Hopp |
d4be56 |
rettv->vval.v_number = (varnumber_T)(t - str);
|
|
Karsten Hopp |
d4be56 |
#else
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 9212,9217 ****
|
|
Karsten Hopp |
d4be56 |
--- 9216,9243 ----
|
|
Karsten Hopp |
d4be56 |
#endif
|
|
Karsten Hopp |
d4be56 |
}
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
+ /*
|
|
Karsten Hopp |
d4be56 |
+ * "byteidx()" function
|
|
Karsten Hopp |
d4be56 |
+ */
|
|
Karsten Hopp |
d4be56 |
+ static void
|
|
Karsten Hopp |
d4be56 |
+ f_byteidx(argvars, rettv)
|
|
Karsten Hopp |
d4be56 |
+ typval_T *argvars;
|
|
Karsten Hopp |
d4be56 |
+ typval_T *rettv;
|
|
Karsten Hopp |
d4be56 |
+ {
|
|
Karsten Hopp |
d4be56 |
+ byteidx(argvars, rettv, FALSE);
|
|
Karsten Hopp |
d4be56 |
+ }
|
|
Karsten Hopp |
d4be56 |
+
|
|
Karsten Hopp |
d4be56 |
+ /*
|
|
Karsten Hopp |
d4be56 |
+ * "byteidxcomp()" function
|
|
Karsten Hopp |
d4be56 |
+ */
|
|
Karsten Hopp |
d4be56 |
+ static void
|
|
Karsten Hopp |
d4be56 |
+ f_byteidxcomp(argvars, rettv)
|
|
Karsten Hopp |
d4be56 |
+ typval_T *argvars;
|
|
Karsten Hopp |
d4be56 |
+ typval_T *rettv;
|
|
Karsten Hopp |
d4be56 |
+ {
|
|
Karsten Hopp |
d4be56 |
+ byteidx(argvars, rettv, TRUE);
|
|
Karsten Hopp |
d4be56 |
+ }
|
|
Karsten Hopp |
d4be56 |
+
|
|
Karsten Hopp |
d4be56 |
int
|
|
Karsten Hopp |
d4be56 |
func_call(name, args, selfdict, rettv)
|
|
Karsten Hopp |
d4be56 |
char_u *name;
|
|
Karsten Hopp |
d4be56 |
*** ../vim-7.4.056/src/testdir/test69.in 2013-03-07 18:30:50.000000000 +0100
|
|
Karsten Hopp |
d4be56 |
--- src/testdir/test69.in 2013-11-02 22:46:02.000000000 +0100
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 1,6 ****
|
|
Karsten Hopp |
d4be56 |
--- 1,7 ----
|
|
Karsten Hopp |
d4be56 |
Test for multi-byte text formatting.
|
|
Karsten Hopp |
d4be56 |
Also test, that 'mps' with multibyte chars works.
|
|
Karsten Hopp |
d4be56 |
And test "ra" on multi-byte characters.
|
|
Karsten Hopp |
d4be56 |
+ Also test byteidx() and byteidxcomp()
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
STARTTEST
|
|
Karsten Hopp |
d4be56 |
:so mbyte.vim
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 154,159 ****
|
|
Karsten Hopp |
d4be56 |
--- 155,175 ----
|
|
Karsten Hopp |
d4be56 |
aab
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
STARTTEST
|
|
Karsten Hopp |
d4be56 |
+ :let a = '.é.' " one char of two bytes
|
|
Karsten Hopp |
d4be56 |
+ :let b = '.é.' " normal e with composing char
|
|
Karsten Hopp |
d4be56 |
+ /^byteidx
|
|
Karsten Hopp |
d4be56 |
+ :put =string([byteidx(a, 0), byteidx(a, 1), byteidx(a, 2), byteidx(a, 3), byteidx(a, 4)])
|
|
Karsten Hopp |
d4be56 |
+ :put =string([byteidx(b, 0), byteidx(b, 1), byteidx(b, 2), byteidx(b, 3), byteidx(b, 4)])
|
|
Karsten Hopp |
d4be56 |
+ /^byteidxcomp
|
|
Karsten Hopp |
d4be56 |
+ :put =string([byteidxcomp(a, 0), byteidxcomp(a, 1), byteidxcomp(a, 2), byteidxcomp(a, 3), byteidxcomp(a, 4)])
|
|
Karsten Hopp |
d4be56 |
+ :let b = '.é.'
|
|
Karsten Hopp |
d4be56 |
+ :put =string([byteidxcomp(b, 0), byteidxcomp(b, 1), byteidxcomp(b, 2), byteidxcomp(b, 3), byteidxcomp(b, 4), byteidxcomp(b, 5)])
|
|
Karsten Hopp |
d4be56 |
+ ENDTEST
|
|
Karsten Hopp |
d4be56 |
+
|
|
Karsten Hopp |
d4be56 |
+ byteidx
|
|
Karsten Hopp |
d4be56 |
+ byteidxcomp
|
|
Karsten Hopp |
d4be56 |
+
|
|
Karsten Hopp |
d4be56 |
+ STARTTEST
|
|
Karsten Hopp |
d4be56 |
:g/^STARTTEST/.,/^ENDTEST/d
|
|
Karsten Hopp |
d4be56 |
:1;/^Results/,$wq! test.out
|
|
Karsten Hopp |
d4be56 |
ENDTEST
|
|
Karsten Hopp |
d4be56 |
*** ../vim-7.4.056/src/testdir/test69.ok 2013-03-07 18:31:32.000000000 +0100
|
|
Karsten Hopp |
d4be56 |
--- src/testdir/test69.ok 2013-11-02 22:43:25.000000000 +0100
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 149,151 ****
|
|
Karsten Hopp |
d4be56 |
--- 149,159 ----
|
|
Karsten Hopp |
d4be56 |
aaaa
|
|
Karsten Hopp |
d4be56 |
aaa
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
+
|
|
Karsten Hopp |
d4be56 |
+ byteidx
|
|
Karsten Hopp |
d4be56 |
+ [0, 1, 3, 4, -1]
|
|
Karsten Hopp |
d4be56 |
+ [0, 1, 4, 5, -1]
|
|
Karsten Hopp |
d4be56 |
+ byteidxcomp
|
|
Karsten Hopp |
d4be56 |
+ [0, 1, 3, 4, -1]
|
|
Karsten Hopp |
d4be56 |
+ [0, 1, 2, 4, 5, -1]
|
|
Karsten Hopp |
d4be56 |
+
|
|
Karsten Hopp |
d4be56 |
*** ../vim-7.4.056/runtime/doc/eval.txt 2013-08-10 13:24:53.000000000 +0200
|
|
Karsten Hopp |
d4be56 |
--- runtime/doc/eval.txt 2013-11-02 23:27:24.000000000 +0100
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 1712,1717 ****
|
|
Karsten Hopp |
d4be56 |
--- 1713,1719 ----
|
|
Karsten Hopp |
d4be56 |
bufwinnr( {expr}) Number window number of buffer {expr}
|
|
Karsten Hopp |
d4be56 |
byte2line( {byte}) Number line number at byte count {byte}
|
|
Karsten Hopp |
d4be56 |
byteidx( {expr}, {nr}) Number byte index of {nr}'th char in {expr}
|
|
Karsten Hopp |
d4be56 |
+ byteidxcomp( {expr}, {nr}) Number byte index of {nr}'th char in {expr}
|
|
Karsten Hopp |
d4be56 |
call( {func}, {arglist} [, {dict}])
|
|
Karsten Hopp |
d4be56 |
any call {func} with arguments {arglist}
|
|
Karsten Hopp |
d4be56 |
ceil( {expr}) Float round {expr} up
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 2260,2266 ****
|
|
Karsten Hopp |
d4be56 |
{expr}. Use zero for the first character, it returns zero.
|
|
Karsten Hopp |
d4be56 |
This function is only useful when there are multibyte
|
|
Karsten Hopp |
d4be56 |
characters, otherwise the returned value is equal to {nr}.
|
|
Karsten Hopp |
d4be56 |
! Composing characters are counted as a separate character.
|
|
Karsten Hopp |
d4be56 |
Example : >
|
|
Karsten Hopp |
d4be56 |
echo matchstr(str, ".", byteidx(str, 3))
|
|
Karsten Hopp |
d4be56 |
< will display the fourth character. Another way to do the
|
|
Karsten Hopp |
d4be56 |
--- 2262,2271 ----
|
|
Karsten Hopp |
d4be56 |
{expr}. Use zero for the first character, it returns zero.
|
|
Karsten Hopp |
d4be56 |
This function is only useful when there are multibyte
|
|
Karsten Hopp |
d4be56 |
characters, otherwise the returned value is equal to {nr}.
|
|
Karsten Hopp |
d4be56 |
! Composing characters are not counted separately, their byte
|
|
Karsten Hopp |
d4be56 |
! length is added to the preceding base character. See
|
|
Karsten Hopp |
d4be56 |
! |byteidxcomp()| below for counting composing characters
|
|
Karsten Hopp |
d4be56 |
! separately.
|
|
Karsten Hopp |
d4be56 |
Example : >
|
|
Karsten Hopp |
d4be56 |
echo matchstr(str, ".", byteidx(str, 3))
|
|
Karsten Hopp |
d4be56 |
< will display the fourth character. Another way to do the
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 2269,2275 ****
|
|
Karsten Hopp |
d4be56 |
echo strpart(s, 0, byteidx(s, 1))
|
|
Karsten Hopp |
d4be56 |
< If there are less than {nr} characters -1 is returned.
|
|
Karsten Hopp |
d4be56 |
If there are exactly {nr} characters the length of the string
|
|
Karsten Hopp |
d4be56 |
! is returned.
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
call({func}, {arglist} [, {dict}]) *call()* *E699*
|
|
Karsten Hopp |
d4be56 |
Call function {func} with the items in |List| {arglist} as
|
|
Karsten Hopp |
d4be56 |
--- 2274,2293 ----
|
|
Karsten Hopp |
d4be56 |
echo strpart(s, 0, byteidx(s, 1))
|
|
Karsten Hopp |
d4be56 |
< If there are less than {nr} characters -1 is returned.
|
|
Karsten Hopp |
d4be56 |
If there are exactly {nr} characters the length of the string
|
|
Karsten Hopp |
d4be56 |
! in bytes is returned.
|
|
Karsten Hopp |
d4be56 |
!
|
|
Karsten Hopp |
d4be56 |
! byteidxcomp({expr}, {nr}) *byteidxcomp()*
|
|
Karsten Hopp |
d4be56 |
! Like byteidx(), except that a composing character is counted
|
|
Karsten Hopp |
d4be56 |
! as a separate character. Example: >
|
|
Karsten Hopp |
d4be56 |
! let s = 'e' . nr2char(0x301)
|
|
Karsten Hopp |
d4be56 |
! echo byteidx(s, 1)
|
|
Karsten Hopp |
d4be56 |
! echo byteidxcomp(s, 1)
|
|
Karsten Hopp |
d4be56 |
! echo byteidxcomp(s, 2)
|
|
Karsten Hopp |
d4be56 |
! < The first and third echo result in 3 ('e' plus composing
|
|
Karsten Hopp |
d4be56 |
! character is 3 bytes), the second echo results in 1 ('e' is
|
|
Karsten Hopp |
d4be56 |
! one byte).
|
|
Karsten Hopp |
d4be56 |
! Only works different from byteidx() when 'encoding' is set to
|
|
Karsten Hopp |
d4be56 |
! a Unicode encoding.
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
call({func}, {arglist} [, {dict}]) *call()* *E699*
|
|
Karsten Hopp |
d4be56 |
Call function {func} with the items in |List| {arglist} as
|
|
Karsten Hopp |
d4be56 |
*** ../vim-7.4.056/src/version.c 2013-11-02 21:49:28.000000000 +0100
|
|
Karsten Hopp |
d4be56 |
--- src/version.c 2013-11-02 22:45:13.000000000 +0100
|
|
Karsten Hopp |
d4be56 |
***************
|
|
Karsten Hopp |
d4be56 |
*** 740,741 ****
|
|
Karsten Hopp |
d4be56 |
--- 740,743 ----
|
|
Karsten Hopp |
d4be56 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
d4be56 |
+ /**/
|
|
Karsten Hopp |
d4be56 |
+ 57,
|
|
Karsten Hopp |
d4be56 |
/**/
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
--
|
|
Karsten Hopp |
d4be56 |
Any sufficiently advanced technology is indistinguishable from magic.
|
|
Karsten Hopp |
d4be56 |
Arthur C. Clarke
|
|
Karsten Hopp |
d4be56 |
Any sufficiently advanced bug is indistinguishable from a feature.
|
|
Karsten Hopp |
d4be56 |
Rich Kulawiec
|
|
Karsten Hopp |
d4be56 |
|
|
Karsten Hopp |
d4be56 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
d4be56 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
d4be56 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
d4be56 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|