From: Thomas Wouters <thomas@python.org>
Date: Wed, 1 Mar 2006 21:37:32 +0000 (+0000)
Subject: Make Py_ssize_t-clean.
X-Git-Tag: v2.5a0~428
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f98db65e52015dc446d20e8cbe9c0fd522f81ee5;p=python

Make Py_ssize_t-clean.
---

diff --git a/Modules/binascii.c b/Modules/binascii.c
index 3b9a44fa61..f4d5cf0822 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -53,6 +53,7 @@
 ** Brandon Long, September 2001.
 */
 
+#include PY_SSIZE_T_CLEAN
 
 #include "Python.h"
 
@@ -189,7 +190,7 @@ binascii_a2b_uu(PyObject *self, PyObject *args)
 	unsigned char this_ch;
 	unsigned int leftchar = 0;
 	PyObject *rv;
-	int ascii_len, bin_len;
+	Py_ssize_t ascii_len, bin_len;
 
 	if ( !PyArg_ParseTuple(args, "t#:a2b_uu", &ascii_data, &ascii_len) )
 		return NULL;
@@ -265,7 +266,7 @@ binascii_b2a_uu(PyObject *self, PyObject *args)
 	unsigned char this_ch;
 	unsigned int leftchar = 0;
 	PyObject *rv;
-	int bin_len;
+	Py_ssize_t bin_len;
 
 	if ( !PyArg_ParseTuple(args, "s#:b2a_uu", &bin_data, &bin_len) )
 		return NULL;
@@ -307,7 +308,7 @@ binascii_b2a_uu(PyObject *self, PyObject *args)
 
 
 static int
-binascii_find_valid(unsigned char *s, int slen, int num)
+binascii_find_valid(unsigned char *s, Py_ssize_t slen, int num)
 {
 	/* Finds & returns the (num+1)th
 	** valid character for base64, or -1 if none.
@@ -341,7 +342,7 @@ binascii_a2b_base64(PyObject *self, PyObject *args)
 	unsigned char this_ch;
 	unsigned int leftchar = 0;
 	PyObject *rv;
-	int ascii_len, bin_len;
+	Py_ssize_t ascii_len, bin_len;
 	int quad_pos = 0;
 
 	if ( !PyArg_ParseTuple(args, "t#:a2b_base64", &ascii_data, &ascii_len) )
@@ -432,7 +433,7 @@ binascii_b2a_base64(PyObject *self, PyObject *args)
 	unsigned char this_ch;
 	unsigned int leftchar = 0;
 	PyObject *rv;
-	int bin_len;
+	Py_ssize_t bin_len;
 
 	if ( !PyArg_ParseTuple(args, "s#:b2a_base64", &bin_data, &bin_len) )
 		return NULL;
@@ -485,7 +486,7 @@ binascii_a2b_hqx(PyObject *self, PyObject *args)
 	unsigned char this_ch;
 	unsigned int leftchar = 0;
 	PyObject *rv;
-	int len;
+	Py_ssize_t len;
 	int done = 0;
 
 	if ( !PyArg_ParseTuple(args, "t#:a2b_hqx", &ascii_data, &len) )
@@ -549,7 +550,7 @@ binascii_rlecode_hqx(PyObject *self, PyObject *args)
 	unsigned char *in_data, *out_data;
 	PyObject *rv;
 	unsigned char ch;
-	int in, inend, len;
+	Py_ssize_t in, inend, len;
 
 	if ( !PyArg_ParseTuple(args, "s#:rlecode_hqx", &in_data, &len) )
 		return NULL;
@@ -598,7 +599,7 @@ binascii_b2a_hqx(PyObject *self, PyObject *args)
 	unsigned char this_ch;
 	unsigned int leftchar = 0;
 	PyObject *rv;
-	int len;
+	Py_ssize_t len;
 
 	if ( !PyArg_ParseTuple(args, "s#:b2a_hqx", &bin_data, &len) )
 		return NULL;
@@ -636,7 +637,7 @@ binascii_rledecode_hqx(PyObject *self, PyObject *args)
 	unsigned char *in_data, *out_data;
 	unsigned char in_byte, in_repeat;
 	PyObject *rv;
-	int in_len, out_len, out_len_left;
+	Py_ssize_t in_len, out_len, out_len_left;
 
 	if ( !PyArg_ParseTuple(args, "s#:rledecode_hqx", &in_data, &in_len) )
 		return NULL;
@@ -732,7 +733,7 @@ binascii_crc_hqx(PyObject *self, PyObject *args)
 {
 	unsigned char *bin_data;
 	unsigned int crc;
-	int len;
+	Py_ssize_t len;
 
 	if ( !PyArg_ParseTuple(args, "s#i:crc_hqx", &bin_data, &len, &crc) )
 		return NULL;
@@ -870,7 +871,7 @@ binascii_crc32(PyObject *self, PyObject *args)
 { /* By Jim Ahlstrom; All rights transferred to CNRI */
 	unsigned char *bin_data;
 	unsigned long crc = 0UL;	/* initial value of CRC */
-	int len;
+	Py_ssize_t len;
 	long result;
 
 	if ( !PyArg_ParseTuple(args, "s#|l:crc32", &bin_data, &len, &crc) )
@@ -903,10 +904,10 @@ static PyObject *
 binascii_hexlify(PyObject *self, PyObject *args)
 {
 	char* argbuf;
-	int arglen;
+	Py_ssize_t arglen;
 	PyObject *retval;
 	char* retbuf;
-	int i, j;
+	Py_ssize_t i, j;
 
 	if (!PyArg_ParseTuple(args, "t#:b2a_hex", &argbuf, &arglen))
 		return NULL;
@@ -960,10 +961,10 @@ static PyObject *
 binascii_unhexlify(PyObject *self, PyObject *args)
 {
 	char* argbuf;
-	int arglen;
+	Py_ssize_t arglen;
 	PyObject *retval;
 	char* retbuf;
-	int i, j;
+	Py_ssize_t i, j;
 
 	if (!PyArg_ParseTuple(args, "s#:a2b_hex", &argbuf, &arglen))
 		return NULL;
@@ -1030,7 +1031,7 @@ binascii_a2b_qp(PyObject *self, PyObject *args, PyObject *kwargs)
 	unsigned int in, out;
 	char ch;
 	unsigned char *data, *odata;
-	unsigned int datalen = 0;
+	Py_ssize_t datalen = 0;
 	PyObject *rv;
 	static char *kwlist[] = {"data", "header", NULL};
 	int header = 0;
@@ -1130,7 +1131,7 @@ binascii_b2a_qp (PyObject *self, PyObject *args, PyObject *kwargs)
 {
 	unsigned int in, out;
 	unsigned char *data, *odata;
-	unsigned int datalen = 0, odatalen = 0;
+	Py_ssize_t datalen = 0, odatalen = 0;
 	PyObject *rv;
 	unsigned int linelen = 0;
 	static char *kwlist[] = {"data", "quotetabs", "istext",