comparison mercurial/diffhelpers.c @ 16693:f1aa3010642f

diffhelpers: use Py_ssize_t in _fix_newline() Eliminates mercurial/diffhelpers.c(23) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data mercurial/diffhelpers.c(26) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data mercurial/diffhelpers.c(27) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data mercurial/diffhelpers.c(30) : warning C4244: 'initializing' : conversion from 'Py_ssize_t' to 'int', possible loss of data when compiling for Windows x64 target using the Microsoft compiler.
author Adrian Buehlmann <adrian@cadifra.com>
date Sat, 12 May 2012 12:07:18 +0200
parents 9e40bc4c1bde
children 797b76205408
comparison
equal deleted inserted replaced
16692:b9969574540a 16693:f1aa3010642f
18 18
19 19
20 /* fixup the last lines of a and b when the patch has no newline at eof */ 20 /* fixup the last lines of a and b when the patch has no newline at eof */
21 static void _fix_newline(PyObject *hunk, PyObject *a, PyObject *b) 21 static void _fix_newline(PyObject *hunk, PyObject *a, PyObject *b)
22 { 22 {
23 int hunksz = PyList_Size(hunk); 23 Py_ssize_t hunksz = PyList_Size(hunk);
24 PyObject *s = PyList_GET_ITEM(hunk, hunksz-1); 24 PyObject *s = PyList_GET_ITEM(hunk, hunksz-1);
25 char *l = PyBytes_AsString(s); 25 char *l = PyBytes_AsString(s);
26 int alen = PyList_Size(a); 26 Py_ssize_t alen = PyList_Size(a);
27 int blen = PyList_Size(b); 27 Py_ssize_t blen = PyList_Size(b);
28 char c = l[0]; 28 char c = l[0];
29 PyObject *hline; 29 PyObject *hline;
30 int sz = PyBytes_GET_SIZE(s); 30 Py_ssize_t sz = PyBytes_GET_SIZE(s);
31 31
32 if (sz > 1 && l[sz-2] == '\r') 32 if (sz > 1 && l[sz-2] == '\r')
33 /* tolerate CRLF in last line */ 33 /* tolerate CRLF in last line */
34 sz -= 1; 34 sz -= 1;
35 35