comparison mercurial/diffhelpers.c @ 16694:797b76205408

diffhelpers: use Py_ssize_t in addlines() Eliminates mercurial/diffhelpers.c(81) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data mercurial/diffhelpers.c(82) : warning C4244: '=' : 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 13:21:08 +0200
parents f1aa3010642f
children 0a0933d3d59c
comparison
equal deleted inserted replaced
16693:f1aa3010642f 16694:797b76205408
55 return NULL; 55 return NULL;
56 _fix_newline(hunk, a, b); 56 _fix_newline(hunk, a, b);
57 return Py_BuildValue("l", 0); 57 return Py_BuildValue("l", 0);
58 } 58 }
59 59
60 #if (PY_VERSION_HEX < 0x02050000)
61 static const char *addlines_format = "OOiiOO";
62 #else
63 static const char *addlines_format = "OOnnOO";
64 #endif
65
60 /* 66 /*
61 * read lines from fp into the hunk. The hunk is parsed into two arrays 67 * read lines from fp into the hunk. The hunk is parsed into two arrays
62 * a and b. a gets the old state of the text, b gets the new state 68 * a and b. a gets the old state of the text, b gets the new state
63 * The control char from the hunk is saved when inserting into a, but not b 69 * The control char from the hunk is saved when inserting into a, but not b
64 * (for performance while deleting files) 70 * (for performance while deleting files)
66 static PyObject * 72 static PyObject *
67 addlines(PyObject *self, PyObject *args) 73 addlines(PyObject *self, PyObject *args)
68 { 74 {
69 75
70 PyObject *fp, *hunk, *a, *b, *x; 76 PyObject *fp, *hunk, *a, *b, *x;
71 int i; 77 Py_ssize_t i;
72 int lena, lenb; 78 Py_ssize_t lena, lenb;
73 int num; 79 Py_ssize_t num;
74 int todoa, todob; 80 Py_ssize_t todoa, todob;
75 char *s, c; 81 char *s, c;
76 PyObject *l; 82 PyObject *l;
77 if (!PyArg_ParseTuple(args, "OOiiOO", &fp, &hunk, &lena, &lenb, &a, &b)) 83 if (!PyArg_ParseTuple(args, addlines_format,
84 &fp, &hunk, &lena, &lenb, &a, &b))
78 return NULL; 85 return NULL;
79 86
80 while (1) { 87 while (1) {
81 todoa = lena - PyList_Size(a); 88 todoa = lena - PyList_Size(a);
82 todob = lenb - PyList_Size(b); 89 todob = lenb - PyList_Size(b);