Mercurial > vim
comparison src/if_py_both.h @ 4389:736b8e18a3bc v7.3.943
updated for version 7.3.943
Problem: Python: Negative indices were failing.
Solution: Fix negative indices. Add tests. (ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 12 May 2013 21:16:23 +0200 |
parents | 358c10968c7f |
children | 80eea7a9d6b9 |
comparison
equal
deleted
inserted
replaced
4388:a38216d77e73 | 4389:736b8e18a3bc |
---|---|
2392 return NULL; | 2392 return NULL; |
2393 | 2393 |
2394 if (end == -1) | 2394 if (end == -1) |
2395 end = self->buf->b_ml.ml_line_count; | 2395 end = self->buf->b_ml.ml_line_count; |
2396 | 2396 |
2397 if (n < 0) | |
2398 n += end - start + 1; | |
2399 | |
2397 if (n < 0 || n > end - start) | 2400 if (n < 0 || n > end - start) |
2398 { | 2401 { |
2399 PyErr_SetString(PyExc_IndexError, _("line number out of range")); | 2402 PyErr_SetString(PyExc_IndexError, _("line number out of range")); |
2400 return NULL; | 2403 return NULL; |
2401 } | 2404 } |
2438 if (CheckBuffer(self)) | 2441 if (CheckBuffer(self)) |
2439 return -1; | 2442 return -1; |
2440 | 2443 |
2441 if (end == -1) | 2444 if (end == -1) |
2442 end = self->buf->b_ml.ml_line_count; | 2445 end = self->buf->b_ml.ml_line_count; |
2446 | |
2447 if (n < 0) | |
2448 n += end - start + 1; | |
2443 | 2449 |
2444 if (n < 0 || n > end - start) | 2450 if (n < 0 || n > end - start) |
2445 { | 2451 { |
2446 PyErr_SetString(PyExc_IndexError, _("line number out of range")); | 2452 PyErr_SetString(PyExc_IndexError, _("line number out of range")); |
2447 return -1; | 2453 return -1; |