diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2011-10-01 20:49:36 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-27 13:27:51 +0000 |
commit | 921ced43c48c1d170452a7b251b94cc96ec8dd44 (patch) | |
tree | 3c4a89176ea67fe4c7bf7b375488361a823c95fa /mercurial/diffhelpers.c | |
parent | 9039c805b0a7e36220101323f82735f08a104b37 (diff) | |
download | mercurial-tarball-921ced43c48c1d170452a7b251b94cc96ec8dd44.tar.gz |
Imported from /srv/lorry/lorry-area/mercurial-tarball/mercurial-1.9.3.tar.gz.HEADmercurial-1.9.3master
Diffstat (limited to 'mercurial/diffhelpers.c')
-rw-r--r-- | mercurial/diffhelpers.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/mercurial/diffhelpers.c b/mercurial/diffhelpers.c index b0fd766..aa2a275 100644 --- a/mercurial/diffhelpers.c +++ b/mercurial/diffhelpers.c @@ -20,14 +20,14 @@ static PyObject *diffhelpers_Error; /* fixup the last lines of a and b when the patch has no newline at eof */ static void _fix_newline(PyObject *hunk, PyObject *a, PyObject *b) { - Py_ssize_t hunksz = PyList_Size(hunk); + int hunksz = PyList_Size(hunk); PyObject *s = PyList_GET_ITEM(hunk, hunksz-1); char *l = PyBytes_AsString(s); - Py_ssize_t alen = PyList_Size(a); - Py_ssize_t blen = PyList_Size(b); + int alen = PyList_Size(a); + int blen = PyList_Size(b); char c = l[0]; PyObject *hline; - Py_ssize_t sz = PyBytes_GET_SIZE(s); + int sz = PyBytes_GET_SIZE(s); if (sz > 1 && l[sz-2] == '\r') /* tolerate CRLF in last line */ @@ -57,12 +57,6 @@ fix_newline(PyObject *self, PyObject *args) 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 @@ -74,14 +68,13 @@ addlines(PyObject *self, PyObject *args) { PyObject *fp, *hunk, *a, *b, *x; - Py_ssize_t i; - Py_ssize_t lena, lenb; - Py_ssize_t num; - Py_ssize_t todoa, todob; + int i; + int lena, lenb; + int num; + int todoa, todob; char *s, c; PyObject *l; - if (!PyArg_ParseTuple(args, addlines_format, - &fp, &hunk, &lena, &lenb, &a, &b)) + if (!PyArg_ParseTuple(args, "OOiiOO", &fp, &hunk, &lena, &lenb, &a, &b)) return NULL; while (1) { @@ -134,15 +127,15 @@ testhunk(PyObject *self, PyObject *args) PyObject *a, *b; long bstart; - Py_ssize_t alen, blen; - Py_ssize_t i; + int alen, blen; + int i; char *sa, *sb; if (!PyArg_ParseTuple(args, "OOl", &a, &b, &bstart)) return NULL; alen = PyList_Size(a); blen = PyList_Size(b); - if (alen > blen - bstart || bstart < 0) { + if (alen > blen - bstart) { return Py_BuildValue("l", -1); } for (i = 0; i < alen; i++) { |