Py_ssize_t-ify.

This commit is contained in:
Thomas Wouters 2006-03-01 01:05:10 +00:00
parent 9d63ccae90
commit 68bc4f9ae5
1 changed files with 10 additions and 5 deletions

View File

@ -13,6 +13,8 @@
/* See also ../Dos/dosmodule.c */ /* See also ../Dos/dosmodule.c */
#define PY_SSIZE_T_CLEAN
#include "Python.h" #include "Python.h"
#include "structseq.h" #include "structseq.h"
@ -1759,7 +1761,7 @@ posix_listdir(PyObject *self, PyObject *args)
#define MAX_PATH CCHMAXPATH #define MAX_PATH CCHMAXPATH
#endif #endif
char *name, *pt; char *name, *pt;
int len; Py_ssize_t len;
PyObject *d, *v; PyObject *d, *v;
char namebuf[MAX_PATH+5]; char namebuf[MAX_PATH+5];
HDIR hdir = 1; HDIR hdir = 1;
@ -1899,7 +1901,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
/* assume encoded strings wont more than double no of chars */ /* assume encoded strings wont more than double no of chars */
char inbuf[MAX_PATH*2]; char inbuf[MAX_PATH*2];
char *inbufp = inbuf; char *inbufp = inbuf;
int insize = sizeof(inbuf)/sizeof(inbuf[0]); Py_ssize_t insize;
char outbuf[MAX_PATH*2]; char outbuf[MAX_PATH*2];
char *temp; char *temp;
#ifdef Py_WIN_WIDE_FILENAMES #ifdef Py_WIN_WIDE_FILENAMES
@ -1919,6 +1921,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
PyErr_Clear(); PyErr_Clear();
} }
#endif #endif
/* XXX(twouters) Why use 'et#' here at all? insize isn't used */
if (!PyArg_ParseTuple (args, "et#:_getfullpathname", if (!PyArg_ParseTuple (args, "et#:_getfullpathname",
Py_FileSystemDefaultEncoding, &inbufp, Py_FileSystemDefaultEncoding, &inbufp,
&insize)) &insize))
@ -5590,16 +5593,18 @@ Write a string to a file descriptor.");
static PyObject * static PyObject *
posix_write(PyObject *self, PyObject *args) posix_write(PyObject *self, PyObject *args)
{ {
int fd, size; int fd;
Py_ssize_t size;
char *buffer; char *buffer;
if (!PyArg_ParseTuple(args, "is#:write", &fd, &buffer, &size)) if (!PyArg_ParseTuple(args, "is#:write", &fd, &buffer, &size))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
size = write(fd, buffer, size); size = write(fd, buffer, (size_t)size);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (size < 0) if (size < 0)
return posix_error(); return posix_error();
return PyInt_FromLong((long)size); return PyInt_FromSsize_t(size);
} }