]> granicus.if.org Git - python/commitdiff
Fix more ssize_t problems.
authorMartin v. Löwis <martin@v.loewis.de>
Sat, 22 Apr 2006 11:15:41 +0000 (11:15 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sat, 22 Apr 2006 11:15:41 +0000 (11:15 +0000)
Modules/cjkcodecs/multibytecodec.c
Modules/operator.c
Modules/posixmodule.c

index aa0096aeb3cecf94dc8e71c987a6d68ca5e997dd..7e6aedc03764534c64e40d3a4545768416a0aa56 100644 (file)
@@ -831,7 +831,7 @@ decoder_feed_buffer(MultibyteStatefulDecoderContext *ctx,
 {
        while (buf->inbuf < buf->inbuf_end) {
                Py_ssize_t inleft, outleft;
-               int r;
+               Py_ssize_t r;
 
                inleft = (Py_ssize_t)(buf->inbuf_end - buf->inbuf);
                outleft = (Py_ssize_t)(buf->outbuf_end - buf->outbuf);
index 25b399994695315f03e1e468d757342be7074136..7fc1f8abe820e3dc8cd17dbba2b97d91e78fcb69 100644 (file)
@@ -48,6 +48,12 @@ used for special class methods; variants without leading and trailing\n\
   if(-1 == (r=AOP(a1,a2))) return NULL; \
   return PyInt_FromLong(r); }
 
+#define spamn2(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
+  PyObject *a1, *a2; Py_ssize_t r; \
+  if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \
+  if(-1 == (r=AOP(a1,a2))) return NULL; \
+  return PyInt_FromSsize_t(r); }
+
 #define spami2b(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
   PyObject *a1, *a2; long r; \
   if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \
@@ -99,8 +105,8 @@ spam2(op_iconcat       , PySequence_InPlaceConcat)
 spamoi(op_irepeat      , PySequence_InPlaceRepeat)
 spami2b(op_contains     , PySequence_Contains)
 spami2b(sequenceIncludes, PySequence_Contains)
-spami2(indexOf         , PySequence_Index)
-spami2(countOf         , PySequence_Count)
+spamn2(indexOf         , PySequence_Index)
+spamn2(countOf         , PySequence_Count)
 spami(isMappingType    , PyMapping_Check)
 spam2(op_getitem       , PyObject_GetItem)
 spam2n(op_delitem       , PyObject_DelItem)
index b51ba5dc54c56f9d926f0933c6adbdc33372f32b..816e3eb8d54decc0b3074964b0748beb124c9cc1 100644 (file)
@@ -2440,7 +2440,7 @@ posix_execve(PyObject *self, PyObject *args)
        PyObject *key, *val, *keys=NULL, *vals=NULL;
        Py_ssize_t i, pos, argc, envc;
        PyObject *(*getitem)(PyObject *, Py_ssize_t);
-       int lastarg = 0;
+       Py_ssize_t lastarg = 0;
 
        /* execve has three arguments: (path, argv, env), where
           argv is a list or tuple of strings and env is a dictionary
@@ -2581,7 +2581,8 @@ posix_spawnv(PyObject *self, PyObject *args)
        char *path;
        PyObject *argv;
        char **argvlist;
-       int mode, i, argc;
+       int mode, i;
+       Py_ssize_t argc;
        Py_intptr_t spawnval;
        PyObject *(*getitem)(PyObject *, Py_ssize_t);
 
@@ -2670,10 +2671,11 @@ posix_spawnve(PyObject *self, PyObject *args)
        char **argvlist;
        char **envlist;
        PyObject *key, *val, *keys=NULL, *vals=NULL, *res=NULL;
-       int mode, i, pos, argc, envc;
+       int mode, pos, envc;
+       Py_ssize_t argc, i;
        Py_intptr_t spawnval;
        PyObject *(*getitem)(PyObject *, Py_ssize_t);
-       int lastarg = 0;
+       Py_ssize_t lastarg = 0;
 
        /* spawnve has four arguments: (mode, path, argv, env), where
           argv is a list or tuple of strings and env is a dictionary
@@ -4374,7 +4376,7 @@ _PyPopenCreateProcess(char *cmdstring,
                        char modulepath[_MAX_PATH];
                        struct stat statinfo;
                        GetModuleFileName(NULL, modulepath, sizeof(modulepath));
-                       for (i = x = 0; modulepath[i]; i++)
+                       for (x = i = 0; modulepath[i]; i++)
                                if (modulepath[i] == SEP)
                                        x = i+1;
                        modulepath[x] = '\0';