# HG changeset patch # User Adrian Buehlmann # Date 2012-05-12 11:21:08 # Node ID 797b762054089b5a594fe6c0d31ba91d93ed9fdc # Parent f1aa3010642fe599929e4a44b90016401f875a2e 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. diff --git a/mercurial/diffhelpers.c b/mercurial/diffhelpers.c --- a/mercurial/diffhelpers.c +++ b/mercurial/diffhelpers.c @@ -57,6 +57,12 @@ fix_newline(PyObject *self, PyObject *ar return Py_BuildValue("l", 0); } +#if (PY_VERSION_HEX < 0x02050000) +static const char *addlines_format = "OOiiOO"; +#else +static const char *addlines_format = "OOnnOO"; +#endif + /* * read lines from fp into the hunk. The hunk is parsed into two arrays * a and b. a gets the old state of the text, b gets the new state @@ -68,13 +74,14 @@ addlines(PyObject *self, PyObject *args) { PyObject *fp, *hunk, *a, *b, *x; - int i; - int lena, lenb; - int num; - int todoa, todob; + Py_ssize_t i; + Py_ssize_t lena, lenb; + Py_ssize_t num; + Py_ssize_t todoa, todob; char *s, c; PyObject *l; - if (!PyArg_ParseTuple(args, "OOiiOO", &fp, &hunk, &lena, &lenb, &a, &b)) + if (!PyArg_ParseTuple(args, addlines_format, + &fp, &hunk, &lena, &lenb, &a, &b)) return NULL; while (1) {