changeset 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
files mercurial/diffhelpers.c
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/diffhelpers.c	Sat May 12 12:07:18 2012 +0200
+++ b/mercurial/diffhelpers.c	Sat May 12 13:21:08 2012 +0200
@@ -57,6 +57,12 @@
 	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 @@
 {
 
 	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) {