# HG changeset patch # User Yuya Nishihara # Date 1501509486 -32400 # Node ID a22339d389d456f2ee4573ffaa668860335700f6 # Parent 0f4ac3b6dee4d58d9b46f0e6bb95a9d8b478d88d cext: modernize charencode.c to use Py_ssize_t diff -r 0f4ac3b6dee4 -r a22339d389d4 mercurial/cext/charencode.c --- a/mercurial/cext/charencode.c Sun May 21 14:23:22 2017 +0900 +++ b/mercurial/cext/charencode.c Mon Jul 31 22:58:06 2017 +0900 @@ -7,6 +7,7 @@ the GNU General Public License, incorporated herein by reference. */ +#define PY_SSIZE_T_CLEAN #include #include "charencode.h" @@ -57,11 +58,11 @@ /* * Turn a hex-encoded string into binary. */ -PyObject *unhexlify(const char *str, int len) +PyObject *unhexlify(const char *str, Py_ssize_t len) { PyObject *ret; char *d; - int i; + Py_ssize_t i; ret = PyBytes_FromStringAndSize(NULL, len / 2); diff -r 0f4ac3b6dee4 -r a22339d389d4 mercurial/cext/charencode.h --- a/mercurial/cext/charencode.h Sun May 21 14:23:22 2017 +0900 +++ b/mercurial/cext/charencode.h Mon Jul 31 22:58:06 2017 +0900 @@ -18,7 +18,7 @@ NORMCASE_OTHER = 0 }; -PyObject *unhexlify(const char *str, int len); +PyObject *unhexlify(const char *str, Py_ssize_t len); PyObject *asciilower(PyObject *self, PyObject *args); PyObject *asciiupper(PyObject *self, PyObject *args); PyObject *make_file_foldmap(PyObject *self, PyObject *args); diff -r 0f4ac3b6dee4 -r a22339d389d4 mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c Sun May 21 14:23:22 2017 +0900 +++ b/mercurial/cext/parsers.c Mon Jul 31 22:58:06 2017 +0900 @@ -85,7 +85,7 @@ nlen = newline - zero - 1; - node = unhexlify(zero + 1, nlen > 40 ? 40 : (int)nlen); + node = unhexlify(zero + 1, nlen > 40 ? 40 : (Py_ssize_t)nlen); if (!node) goto bail;