|
Karsten Hopp |
50f7bc |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
50f7bc |
Subject: Patch 7.3.943
|
|
Karsten Hopp |
50f7bc |
Fcc: outbox
|
|
Karsten Hopp |
50f7bc |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
50f7bc |
Mime-Version: 1.0
|
|
Karsten Hopp |
50f7bc |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
50f7bc |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
50f7bc |
------------
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
Patch 7.3.943
|
|
Karsten Hopp |
50f7bc |
Problem: Python: Negative indices were failing.
|
|
Karsten Hopp |
50f7bc |
Solution: Fix negative indices. Add tests. (ZyX)
|
|
Karsten Hopp |
50f7bc |
Files: src/if_py_both.h, src/if_python3.c, src/testdir/test86.in,
|
|
Karsten Hopp |
50f7bc |
src/testdir/test86.ok, src/testdir/test87.in,
|
|
Karsten Hopp |
50f7bc |
src/testdir/test87.ok
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
*** ../vim-7.3.942/src/if_py_both.h 2013-05-12 20:36:09.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
--- src/if_py_both.h 2013-05-12 21:10:03.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
***************
|
|
Karsten Hopp |
50f7bc |
*** 2394,2399 ****
|
|
Karsten Hopp |
50f7bc |
--- 2394,2402 ----
|
|
Karsten Hopp |
50f7bc |
if (end == -1)
|
|
Karsten Hopp |
50f7bc |
end = self->buf->b_ml.ml_line_count;
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
+ if (n < 0)
|
|
Karsten Hopp |
50f7bc |
+ n += end - start + 1;
|
|
Karsten Hopp |
50f7bc |
+
|
|
Karsten Hopp |
50f7bc |
if (n < 0 || n > end - start)
|
|
Karsten Hopp |
50f7bc |
{
|
|
Karsten Hopp |
50f7bc |
PyErr_SetString(PyExc_IndexError, _("line number out of range"));
|
|
Karsten Hopp |
50f7bc |
***************
|
|
Karsten Hopp |
50f7bc |
*** 2441,2446 ****
|
|
Karsten Hopp |
50f7bc |
--- 2444,2452 ----
|
|
Karsten Hopp |
50f7bc |
if (end == -1)
|
|
Karsten Hopp |
50f7bc |
end = self->buf->b_ml.ml_line_count;
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
+ if (n < 0)
|
|
Karsten Hopp |
50f7bc |
+ n += end - start + 1;
|
|
Karsten Hopp |
50f7bc |
+
|
|
Karsten Hopp |
50f7bc |
if (n < 0 || n > end - start)
|
|
Karsten Hopp |
50f7bc |
{
|
|
Karsten Hopp |
50f7bc |
PyErr_SetString(PyExc_IndexError, _("line number out of range"));
|
|
Karsten Hopp |
50f7bc |
*** ../vim-7.3.942/src/if_python3.c 2013-05-12 20:36:09.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
--- src/if_python3.c 2013-05-12 21:10:03.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
***************
|
|
Karsten Hopp |
50f7bc |
*** 1114,1120 ****
|
|
Karsten Hopp |
50f7bc |
return NULL;
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
if (PySlice_GetIndicesEx((PyObject *)idx,
|
|
Karsten Hopp |
50f7bc |
! (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
|
|
Karsten Hopp |
50f7bc |
&start, &stop,
|
|
Karsten Hopp |
50f7bc |
&step, &slicelen) < 0)
|
|
Karsten Hopp |
50f7bc |
{
|
|
Karsten Hopp |
50f7bc |
--- 1114,1120 ----
|
|
Karsten Hopp |
50f7bc |
return NULL;
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
if (PySlice_GetIndicesEx((PyObject *)idx,
|
|
Karsten Hopp |
50f7bc |
! (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
|
|
Karsten Hopp |
50f7bc |
&start, &stop,
|
|
Karsten Hopp |
50f7bc |
&step, &slicelen) < 0)
|
|
Karsten Hopp |
50f7bc |
{
|
|
Karsten Hopp |
50f7bc |
***************
|
|
Karsten Hopp |
50f7bc |
*** 1146,1152 ****
|
|
Karsten Hopp |
50f7bc |
return -1;
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
if (PySlice_GetIndicesEx((PyObject *)idx,
|
|
Karsten Hopp |
50f7bc |
! (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
|
|
Karsten Hopp |
50f7bc |
&start, &stop,
|
|
Karsten Hopp |
50f7bc |
&step, &slicelen) < 0)
|
|
Karsten Hopp |
50f7bc |
{
|
|
Karsten Hopp |
50f7bc |
--- 1146,1152 ----
|
|
Karsten Hopp |
50f7bc |
return -1;
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
if (PySlice_GetIndicesEx((PyObject *)idx,
|
|
Karsten Hopp |
50f7bc |
! (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
|
|
Karsten Hopp |
50f7bc |
&start, &stop,
|
|
Karsten Hopp |
50f7bc |
&step, &slicelen) < 0)
|
|
Karsten Hopp |
50f7bc |
{
|
|
Karsten Hopp |
50f7bc |
*** ../vim-7.3.942/src/testdir/test86.in 2013-05-06 03:52:44.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
--- src/testdir/test86.in 2013-05-12 21:11:43.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
***************
|
|
Karsten Hopp |
50f7bc |
*** 475,483 ****
|
|
Karsten Hopp |
50f7bc |
: endtry
|
|
Karsten Hopp |
50f7bc |
: endfor
|
|
Karsten Hopp |
50f7bc |
: call RecVars(oname)
|
|
Karsten Hopp |
50f7bc |
- endtry
|
|
Karsten Hopp |
50f7bc |
:endfor
|
|
Karsten Hopp |
50f7bc |
:only
|
|
Karsten Hopp |
50f7bc |
:endfun
|
|
Karsten Hopp |
50f7bc |
:"
|
|
Karsten Hopp |
50f7bc |
:call Test()
|
|
Karsten Hopp |
50f7bc |
--- 475,524 ----
|
|
Karsten Hopp |
50f7bc |
: endtry
|
|
Karsten Hopp |
50f7bc |
: endfor
|
|
Karsten Hopp |
50f7bc |
: call RecVars(oname)
|
|
Karsten Hopp |
50f7bc |
:endfor
|
|
Karsten Hopp |
50f7bc |
:only
|
|
Karsten Hopp |
50f7bc |
+ :"
|
|
Karsten Hopp |
50f7bc |
+ :" Test buffer object
|
|
Karsten Hopp |
50f7bc |
+ :vnew
|
|
Karsten Hopp |
50f7bc |
+ :put ='First line'
|
|
Karsten Hopp |
50f7bc |
+ :put ='Second line'
|
|
Karsten Hopp |
50f7bc |
+ :put ='Third line'
|
|
Karsten Hopp |
50f7bc |
+ :1 delete _
|
|
Karsten Hopp |
50f7bc |
+ :py b=vim.current.buffer
|
|
Karsten Hopp |
50f7bc |
+ :wincmd w
|
|
Karsten Hopp |
50f7bc |
+ :mark a
|
|
Karsten Hopp |
50f7bc |
+ py << EOF
|
|
Karsten Hopp |
50f7bc |
+ cb = vim.current.buffer
|
|
Karsten Hopp |
50f7bc |
+ # Tests BufferAppend and BufferItem
|
|
Karsten Hopp |
50f7bc |
+ cb.append(b[0])
|
|
Karsten Hopp |
50f7bc |
+ # Tests BufferSlice and BufferAssSlice
|
|
Karsten Hopp |
50f7bc |
+ cb.append('abc') # Will be overwritten
|
|
Karsten Hopp |
50f7bc |
+ cb[-1:] = b[:-2]
|
|
Karsten Hopp |
50f7bc |
+ # Test BufferLength and BufferAssSlice
|
|
Karsten Hopp |
50f7bc |
+ cb.append('def') # Will not be overwritten
|
|
Karsten Hopp |
50f7bc |
+ cb[len(cb):] = b[:]
|
|
Karsten Hopp |
50f7bc |
+ # Test BufferAssItem and BufferMark
|
|
Karsten Hopp |
50f7bc |
+ cb.append('ghi') # Will be overwritten
|
|
Karsten Hopp |
50f7bc |
+ cb[-1] = repr((len(cb) - cb.mark('a')[0], cb.mark('a')[1]))
|
|
Karsten Hopp |
50f7bc |
+ # Test BufferRepr
|
|
Karsten Hopp |
50f7bc |
+ cb.append(repr(cb) + repr(b))
|
|
Karsten Hopp |
50f7bc |
+ # Modify foreign buffer
|
|
Karsten Hopp |
50f7bc |
+ b.append('foo')
|
|
Karsten Hopp |
50f7bc |
+ b[0]='bar'
|
|
Karsten Hopp |
50f7bc |
+ b[0:0]=['baz']
|
|
Karsten Hopp |
50f7bc |
+ vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number)
|
|
Karsten Hopp |
50f7bc |
+ # Test CheckBuffer
|
|
Karsten Hopp |
50f7bc |
+ vim.command('bwipeout! ' + str(b.number))
|
|
Karsten Hopp |
50f7bc |
+ for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'):
|
|
Karsten Hopp |
50f7bc |
+ try:
|
|
Karsten Hopp |
50f7bc |
+ exec(expr)
|
|
Karsten Hopp |
50f7bc |
+ except vim.error:
|
|
Karsten Hopp |
50f7bc |
+ pass
|
|
Karsten Hopp |
50f7bc |
+ else:
|
|
Karsten Hopp |
50f7bc |
+ # Usually a SEGV here
|
|
Karsten Hopp |
50f7bc |
+ # Should not happen in any case
|
|
Karsten Hopp |
50f7bc |
+ cb.append('No exception for ' + expr)
|
|
Karsten Hopp |
50f7bc |
+ EOF
|
|
Karsten Hopp |
50f7bc |
:endfun
|
|
Karsten Hopp |
50f7bc |
:"
|
|
Karsten Hopp |
50f7bc |
:call Test()
|
|
Karsten Hopp |
50f7bc |
*** ../vim-7.3.942/src/testdir/test86.ok 2013-05-06 03:52:44.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
--- src/testdir/test86.ok 2013-05-12 21:11:43.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
***************
|
|
Karsten Hopp |
50f7bc |
*** 306,308 ****
|
|
Karsten Hopp |
50f7bc |
--- 306,321 ----
|
|
Karsten Hopp |
50f7bc |
G: '.,,'
|
|
Karsten Hopp |
50f7bc |
W: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
|
|
Karsten Hopp |
50f7bc |
B: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
|
|
Karsten Hopp |
50f7bc |
+ First line
|
|
Karsten Hopp |
50f7bc |
+ First line
|
|
Karsten Hopp |
50f7bc |
+ def
|
|
Karsten Hopp |
50f7bc |
+ First line
|
|
Karsten Hopp |
50f7bc |
+ Second line
|
|
Karsten Hopp |
50f7bc |
+ Third line
|
|
Karsten Hopp |
50f7bc |
+ (7, 2)
|
|
Karsten Hopp |
50f7bc |
+ <buffer test86.in><buffer >
|
|
Karsten Hopp |
50f7bc |
+ baz
|
|
Karsten Hopp |
50f7bc |
+ bar
|
|
Karsten Hopp |
50f7bc |
+ Second line
|
|
Karsten Hopp |
50f7bc |
+ Third line
|
|
Karsten Hopp |
50f7bc |
+ foo
|
|
Karsten Hopp |
50f7bc |
*** ../vim-7.3.942/src/testdir/test87.in 2013-05-06 03:52:44.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
--- src/testdir/test87.in 2013-05-12 21:11:43.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
***************
|
|
Karsten Hopp |
50f7bc |
*** 444,452 ****
|
|
Karsten Hopp |
50f7bc |
: endtry
|
|
Karsten Hopp |
50f7bc |
: endfor
|
|
Karsten Hopp |
50f7bc |
: call RecVars(oname)
|
|
Karsten Hopp |
50f7bc |
- endtry
|
|
Karsten Hopp |
50f7bc |
:endfor
|
|
Karsten Hopp |
50f7bc |
:only
|
|
Karsten Hopp |
50f7bc |
:endfun
|
|
Karsten Hopp |
50f7bc |
:"
|
|
Karsten Hopp |
50f7bc |
:call Test()
|
|
Karsten Hopp |
50f7bc |
--- 444,493 ----
|
|
Karsten Hopp |
50f7bc |
: endtry
|
|
Karsten Hopp |
50f7bc |
: endfor
|
|
Karsten Hopp |
50f7bc |
: call RecVars(oname)
|
|
Karsten Hopp |
50f7bc |
:endfor
|
|
Karsten Hopp |
50f7bc |
:only
|
|
Karsten Hopp |
50f7bc |
+ :"
|
|
Karsten Hopp |
50f7bc |
+ :" Test buffer object
|
|
Karsten Hopp |
50f7bc |
+ :vnew
|
|
Karsten Hopp |
50f7bc |
+ :put ='First line'
|
|
Karsten Hopp |
50f7bc |
+ :put ='Second line'
|
|
Karsten Hopp |
50f7bc |
+ :put ='Third line'
|
|
Karsten Hopp |
50f7bc |
+ :1 delete _
|
|
Karsten Hopp |
50f7bc |
+ :py3 b=vim.current.buffer
|
|
Karsten Hopp |
50f7bc |
+ :wincmd w
|
|
Karsten Hopp |
50f7bc |
+ :mark a
|
|
Karsten Hopp |
50f7bc |
+ py3 << EOF
|
|
Karsten Hopp |
50f7bc |
+ cb = vim.current.buffer
|
|
Karsten Hopp |
50f7bc |
+ # Tests BufferAppend and BufferItem
|
|
Karsten Hopp |
50f7bc |
+ cb.append(b[0])
|
|
Karsten Hopp |
50f7bc |
+ # Tests BufferSlice and BufferAssSlice
|
|
Karsten Hopp |
50f7bc |
+ cb.append('abc') # Will be overwritten
|
|
Karsten Hopp |
50f7bc |
+ cb[-1:] = b[:-2]
|
|
Karsten Hopp |
50f7bc |
+ # Test BufferLength and BufferAssSlice
|
|
Karsten Hopp |
50f7bc |
+ cb.append('def') # Will not be overwritten
|
|
Karsten Hopp |
50f7bc |
+ cb[len(cb):] = b[:]
|
|
Karsten Hopp |
50f7bc |
+ # Test BufferAssItem and BufferMark
|
|
Karsten Hopp |
50f7bc |
+ cb.append('ghi') # Will be overwritten
|
|
Karsten Hopp |
50f7bc |
+ cb[-1] = repr((len(cb) - cb.mark('a')[0], cb.mark('a')[1]))
|
|
Karsten Hopp |
50f7bc |
+ # Test BufferRepr
|
|
Karsten Hopp |
50f7bc |
+ cb.append(repr(cb) + repr(b))
|
|
Karsten Hopp |
50f7bc |
+ # Modify foreign buffer
|
|
Karsten Hopp |
50f7bc |
+ b.append('foo')
|
|
Karsten Hopp |
50f7bc |
+ b[0]='bar'
|
|
Karsten Hopp |
50f7bc |
+ b[0:0]=['baz']
|
|
Karsten Hopp |
50f7bc |
+ vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number)
|
|
Karsten Hopp |
50f7bc |
+ # Test CheckBuffer
|
|
Karsten Hopp |
50f7bc |
+ vim.command('bwipeout! ' + str(b.number))
|
|
Karsten Hopp |
50f7bc |
+ for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'):
|
|
Karsten Hopp |
50f7bc |
+ try:
|
|
Karsten Hopp |
50f7bc |
+ exec(expr)
|
|
Karsten Hopp |
50f7bc |
+ except vim.error:
|
|
Karsten Hopp |
50f7bc |
+ pass
|
|
Karsten Hopp |
50f7bc |
+ else:
|
|
Karsten Hopp |
50f7bc |
+ # Usually a SEGV here
|
|
Karsten Hopp |
50f7bc |
+ # Should not happen in any case
|
|
Karsten Hopp |
50f7bc |
+ cb.append('No exception for ' + expr)
|
|
Karsten Hopp |
50f7bc |
+ EOF
|
|
Karsten Hopp |
50f7bc |
:endfun
|
|
Karsten Hopp |
50f7bc |
:"
|
|
Karsten Hopp |
50f7bc |
:call Test()
|
|
Karsten Hopp |
50f7bc |
*** ../vim-7.3.942/src/testdir/test87.ok 2013-05-06 03:52:44.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
--- src/testdir/test87.ok 2013-05-12 21:11:43.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
***************
|
|
Karsten Hopp |
50f7bc |
*** 295,297 ****
|
|
Karsten Hopp |
50f7bc |
--- 295,310 ----
|
|
Karsten Hopp |
50f7bc |
G: '.,,'
|
|
Karsten Hopp |
50f7bc |
W: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
|
|
Karsten Hopp |
50f7bc |
B: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
|
|
Karsten Hopp |
50f7bc |
+ First line
|
|
Karsten Hopp |
50f7bc |
+ First line
|
|
Karsten Hopp |
50f7bc |
+ def
|
|
Karsten Hopp |
50f7bc |
+ First line
|
|
Karsten Hopp |
50f7bc |
+ Second line
|
|
Karsten Hopp |
50f7bc |
+ Third line
|
|
Karsten Hopp |
50f7bc |
+ (7, 2)
|
|
Karsten Hopp |
50f7bc |
+ <buffer test87.in><buffer >
|
|
Karsten Hopp |
50f7bc |
+ baz
|
|
Karsten Hopp |
50f7bc |
+ bar
|
|
Karsten Hopp |
50f7bc |
+ Second line
|
|
Karsten Hopp |
50f7bc |
+ Third line
|
|
Karsten Hopp |
50f7bc |
+ foo
|
|
Karsten Hopp |
50f7bc |
*** ../vim-7.3.942/src/version.c 2013-05-12 20:36:09.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
--- src/version.c 2013-05-12 21:11:53.000000000 +0200
|
|
Karsten Hopp |
50f7bc |
***************
|
|
Karsten Hopp |
50f7bc |
*** 730,731 ****
|
|
Karsten Hopp |
50f7bc |
--- 730,733 ----
|
|
Karsten Hopp |
50f7bc |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
50f7bc |
+ /**/
|
|
Karsten Hopp |
50f7bc |
+ 943,
|
|
Karsten Hopp |
50f7bc |
/**/
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
--
|
|
Karsten Hopp |
50f7bc |
Q: Is selling software the same as selling hardware?
|
|
Karsten Hopp |
50f7bc |
A: No, good hardware is sold new, good software has already been used by many.
|
|
Karsten Hopp |
50f7bc |
|
|
Karsten Hopp |
50f7bc |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
50f7bc |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
50f7bc |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
50f7bc |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|