parser: use PyInt_FromSsize_t in index_stats
Eliminates
mercurial/parsers.c(515) : warning C4244: 'function' : conversion from
'Py_ssize_t' to 'long', possible loss of data
mercurial/parsers.c(520) : warning C4244: 'function' : conversion from
'Py_ssize_t' to 'long', possible loss of data
mercurial/parsers.c(521) : warning C4244: 'function' : conversion from
'Py_ssize_t' to 'long', possible loss of data
when compiling for Windows x64 target using the Microsoft compiler.
PyInt_FromSsize_t does not exist for Python 2.4 and earlier, so we define a
fallback in util.h to use PyInt_FromLong when compiling for Python 2.4.
--- a/mercurial/parsers.c Fri May 11 10:53:12 2012 -0700
+++ b/mercurial/parsers.c Wed May 09 09:58:50 2012 +0200
@@ -508,13 +508,13 @@
return NULL;
#define istat(__n, __d) \
- if (PyDict_SetItemString(obj, __d, PyInt_FromLong(self->__n)) == -1) \
+ if (PyDict_SetItemString(obj, __d, PyInt_FromSsize_t(self->__n)) == -1) \
goto bail;
if (self->added) {
Py_ssize_t len = PyList_GET_SIZE(self->added);
if (PyDict_SetItemString(obj, "index entries added",
- PyInt_FromLong(len)) == -1)
+ PyInt_FromSsize_t(len)) == -1)
goto bail;
}
--- a/mercurial/util.h Fri May 11 10:53:12 2012 -0700
+++ b/mercurial/util.h Wed May 09 09:58:50 2012 +0200
@@ -109,6 +109,7 @@
typedef int Py_ssize_t;
typedef Py_ssize_t (*lenfunc)(PyObject *);
typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t);
+#define PyInt_FromSsize_t PyInt_FromLong
#if !defined(PY_SSIZE_T_MIN)
#define PY_SSIZE_T_MAX INT_MAX