]> granicus.if.org Git - python/commitdiff
Keep Microsoft VC happy.
authorGuido van Rossum <guido@python.org>
Fri, 11 Apr 1997 20:44:04 +0000 (20:44 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 11 Apr 1997 20:44:04 +0000 (20:44 +0000)
Modules/arraymodule.c
Modules/rgbimgmodule.c
Modules/rotormodule.c
Modules/structmodule.c
Python/errors.c

index 5862f6c2466d5c0a88f7175a9a0a3fed6d0ea46a..e732f394686a1bfa72d007290d25f71cd961f2a8 100644 (file)
@@ -341,7 +341,7 @@ newarrayobject(size, descr)
        }
        nbytes = size * descr->itemsize;
        /* Check for overflow */
-       if (nbytes / descr->itemsize != size) {
+       if (nbytes / descr->itemsize != (size_t)size) {
                return PyErr_NoMemory();
        }
        op = PyMem_NEW(arrayobject, 1);
@@ -933,7 +933,7 @@ array_tofile(self, args)
                return NULL;
        }
        if (self->ob_size > 0) {
-               if (fwrite(self->ob_item, self->ob_descr->itemsize,
+               if ((int)fwrite(self->ob_item, self->ob_descr->itemsize,
                           self->ob_size, fp) != self->ob_size) {
                        PyErr_SetFromErrno(PyExc_IOError);
                        clearerr(fp);
index 81f9fcbcdddac2d3c04e7cfb4fa54e8cb91af649..d2428d116cd7a1105f0142d5644a970ee94b9f0b 100644 (file)
@@ -163,10 +163,10 @@ putlong(outf, val)
 {
        unsigned char buf[4];
 
-       buf[0] = (val >> 24);
-       buf[1] = (val >> 16);
-       buf[2] = (val >> 8);
-       buf[3] = (val >> 0);
+       buf[0] = (unsigned char) (val >> 24);
+       buf[1] = (unsigned char) (val >> 16);
+       buf[2] = (unsigned char) (val >> 8);
+       buf[3] = (unsigned char) (val >> 0);
        return fwrite(buf, 4, 1, outf);
 }
 
@@ -314,7 +314,7 @@ longimagedata(self, args)
                tablen = ysize * zsize * sizeof(long);
                starttab = (long *)malloc(tablen);
                lengthtab = (long *)malloc(tablen);
-               rlebuflen = 1.05 * xsize +10;
+               rlebuflen = (int) (1.05 * xsize +10);
                rledat = (unsigned char *)malloc(rlebuflen);
                if (!starttab || !lengthtab || !rledat) {
                        PyErr_NoMemory();
@@ -603,7 +603,7 @@ longstoimage(self, args)
 
        starttab = (long *)malloc(tablen);
        lengthtab = (long *)malloc(tablen);
-       rlebuflen = 1.05 * xsize + 10;
+       rlebuflen = (int) (1.05 * xsize + 10);
        rlebuf = (unsigned char *)malloc(rlebuflen);
        lumbuf = (unsigned char *)malloc(xsize * sizeof(long));
        if (!starttab || !lengthtab || !rlebuf || !lumbuf) {
@@ -714,7 +714,7 @@ compressrow(lbuf, rlebuf, z, cnt)
                iptr -= 8;
                count = (iptr - sptr) / 4;
                while (count) {
-                       todo = count > 126 ? 126 : count;
+                       todo = count > 126 ? 126 : (short)count;
                        count -= todo;
                        *optr++ = 0x80 | todo;
                        while (todo > 8) {
@@ -742,10 +742,10 @@ compressrow(lbuf, rlebuf, z, cnt)
                        iptr += 4;
                count = (iptr - sptr) / 4;
                while (count) {
-                       todo = count > 126 ? 126 : count;
+                       todo = count > 126 ? 126 : (short)count;
                        count -= todo;
-                       *optr++ = todo;
-                       *optr++ = cc;
+                       *optr++ = (unsigned char) todo;
+                       *optr++ = (unsigned char) cc;
                }
        }
        *optr++ = 0;
index 6ead93c33df378283d11d2c5dce19f008321f554..65c175871547b81cfb2968605a3c8885b4495d8e 100644 (file)
@@ -93,12 +93,12 @@ set_seed(r)
 }
        
 /* Return the next random number in the range [0.0 .. 1.0) */
-static float
+static double
 r_random(r)
        Rotorobj *r;
 {
        int x, y, z;
-       float val, term;
+       double val, term;
 
        x = r->seed[0];
        y = r->seed[1];
@@ -116,12 +116,12 @@ r_random(r)
        r->seed[1] = y;
        r->seed[2] = z;
 
-       term = (float)(
-               (((float)x)/(float)30269.0) + 
-               (((float)y)/(float)30307.0) + 
-               (((float)z)/(float)30323.0)
+       term = (double)(
+               (((double)x)/(double)30269.0) + 
+               (((double)y)/(double)30307.0) + 
+               (((double)z)/(double)30323.0)
                );
-       val = term - (float)floor((double)term);
+       val = term - (double)floor((double)term);
 
        if (val >= 1.0)
                val = 0.0;
@@ -134,7 +134,7 @@ r_rand(r, s)
        Rotorobj *r;
        short s;
 {
-       return (short)((short)(r_random(r) * (float)s) % s);
+       return (short)((short)(r_random(r) * (double)s) % s);
 }
 
 static void
@@ -340,7 +340,7 @@ RTR_init(r)
        RTR_e_rotors(r);
        RTR_d_rotors(r);
        for (i = 0; i < r->rotors; i++) {
-               r->positions[i] = r_rand(r,r->size);
+               r->positions[i] = (unsigned char) r_rand(r,r->size);
                r->advances[i] = (1+(2*(r_rand(r,r->size/2))));
                RTR_permute_rotor(r,
                                  &(r->e_rotor[(i*r->size)]),
index f0fb4914e0d50ab425ae66e0bc704f9caacc3b87..dbba9b48f20eb44c99ac266b88a43b643aa280c4 100644 (file)
@@ -179,7 +179,7 @@ pack_float(x, p, incr)
        p += incr;
 
        /* Second byte */
-       *p = ((e&1)<<7) | (fbits>>16);
+       *p = (char) (((e&1)<<7) | (fbits>>16));
        p += incr;
 
        /* Third byte */
@@ -255,7 +255,7 @@ pack_double(x, p, incr)
        p += incr;
 
        /* Second byte */
-       *p = ((e&0xF)<<4) | (fhi>>24);
+       *p = (char) (((e&0xF)<<4) | (fhi>>24));
        p += incr;
 
        /* Third byte */
@@ -508,7 +508,7 @@ np_byte(p, v, f)
        long x;
        if (get_long(v, &x) < 0)
                return -1;
-       *p = x;
+       *p = (char)x;
        return 0;
 }
 
@@ -536,7 +536,7 @@ np_short(p, v, f)
        long x;
        if (get_long(v, &x) < 0)
                return -1;
-       * (short *)p = x;
+       * (short *)p = (short)x;
        return 0;
 }
 
@@ -700,7 +700,7 @@ bp_int(p, v, f)
                return -1;
        i = f->size;
        do {
-               p[--i] = x;
+               p[--i] = (char)x;
                x >>= 8;
        } while (i > 0);
        return 0;
@@ -718,7 +718,7 @@ bp_uint(p, v, f)
                return -1;
        i = f->size;
        do {
-               p[--i] = x;
+               p[--i] = (char)x;
                x >>= 8;
        } while (i > 0);
        return 0;
@@ -830,7 +830,7 @@ lp_int(p, v, f)
                return -1;
        i = f->size;
        do {
-               *p++ = x;
+               *p++ = (char)x;
                x >>= 8;
        } while (--i > 0);
        return 0;
@@ -848,7 +848,7 @@ lp_uint(p, v, f)
                return -1;
        i = f->size;
        do {
-               *p++ = x;
+               *p++ = (char)x;
                x >>= 8;
        } while (--i > 0);
        return 0;
index 526b61bba470858dd5e444d1f6ab54caf1f06d75..c7e95282142855b18b0750c3ec725594f95eeb74 100644 (file)
@@ -84,8 +84,10 @@ extern char *PyMac_StrError PROTO((int));
 #endif /* macintosh */
 
 #ifndef __STDC__
+#ifndef MS_WINDOWS
 extern char *strerror PROTO((int));
 #endif
+#endif
 
 /* Last exception stored by err_setval() */