# HG changeset patch # User Shun-ichi GOTO # Date 1192157209 -32400 # Node ID b0e5f44fdeb39c5ddf528396bcad41b0f4f534bd # Parent 7372b6bbc5e6193a08b22529c885937d98603756 mpatch: Define Py_ssize_t for old pythons and use it instead of ssize_t. See also PEP 353. NOTE: Microsoft compilers (8 or earlier) does not have ssize_t. diff --git a/mercurial/mpatch.c b/mercurial/mpatch.c --- a/mercurial/mpatch.c +++ b/mercurial/mpatch.c @@ -24,6 +24,16 @@ #include #include +/* Definitions to get compatibility with python 2.4 and earlier which + does not have Py_ssize_t. See also PEP 353. + Note: msvc (8 or earlier) does not have ssize_t, so we use Py_ssize_t. +*/ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +#define PY_SSIZE_T_MAX INT_MAX +#define PY_SSIZE_T_MIN INT_MIN +#endif + #ifdef _WIN32 # ifdef _MSC_VER /* msvc 6.0 has problems */ @@ -312,7 +322,7 @@ static int apply(char *buf, const char * static struct flist *fold(PyObject *bins, int start, int end) { int len; - ssize_t blen; + Py_ssize_t blen; const char *buffer; if (start + 1 == end) { @@ -339,7 +349,7 @@ patches(PyObject *self, PyObject *args) const char *in; char *out; int len, outlen; - ssize_t inlen; + Py_ssize_t inlen; if (!PyArg_ParseTuple(args, "OO:mpatch", &text, &bins)) return NULL;