mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Keep Microsoft VC happy.
This commit is contained in:
parent
6bf62dad9e
commit
7844e38a98
5 changed files with 31 additions and 29 deletions
|
@ -341,7 +341,7 @@ newarrayobject(size, descr)
|
||||||
}
|
}
|
||||||
nbytes = size * descr->itemsize;
|
nbytes = size * descr->itemsize;
|
||||||
/* Check for overflow */
|
/* Check for overflow */
|
||||||
if (nbytes / descr->itemsize != size) {
|
if (nbytes / descr->itemsize != (size_t)size) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
op = PyMem_NEW(arrayobject, 1);
|
op = PyMem_NEW(arrayobject, 1);
|
||||||
|
@ -933,7 +933,7 @@ array_tofile(self, args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (self->ob_size > 0) {
|
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) {
|
self->ob_size, fp) != self->ob_size) {
|
||||||
PyErr_SetFromErrno(PyExc_IOError);
|
PyErr_SetFromErrno(PyExc_IOError);
|
||||||
clearerr(fp);
|
clearerr(fp);
|
||||||
|
|
|
@ -163,10 +163,10 @@ putlong(outf, val)
|
||||||
{
|
{
|
||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
|
|
||||||
buf[0] = (val >> 24);
|
buf[0] = (unsigned char) (val >> 24);
|
||||||
buf[1] = (val >> 16);
|
buf[1] = (unsigned char) (val >> 16);
|
||||||
buf[2] = (val >> 8);
|
buf[2] = (unsigned char) (val >> 8);
|
||||||
buf[3] = (val >> 0);
|
buf[3] = (unsigned char) (val >> 0);
|
||||||
return fwrite(buf, 4, 1, outf);
|
return fwrite(buf, 4, 1, outf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ longimagedata(self, args)
|
||||||
tablen = ysize * zsize * sizeof(long);
|
tablen = ysize * zsize * sizeof(long);
|
||||||
starttab = (long *)malloc(tablen);
|
starttab = (long *)malloc(tablen);
|
||||||
lengthtab = (long *)malloc(tablen);
|
lengthtab = (long *)malloc(tablen);
|
||||||
rlebuflen = 1.05 * xsize +10;
|
rlebuflen = (int) (1.05 * xsize +10);
|
||||||
rledat = (unsigned char *)malloc(rlebuflen);
|
rledat = (unsigned char *)malloc(rlebuflen);
|
||||||
if (!starttab || !lengthtab || !rledat) {
|
if (!starttab || !lengthtab || !rledat) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
|
@ -603,7 +603,7 @@ longstoimage(self, args)
|
||||||
|
|
||||||
starttab = (long *)malloc(tablen);
|
starttab = (long *)malloc(tablen);
|
||||||
lengthtab = (long *)malloc(tablen);
|
lengthtab = (long *)malloc(tablen);
|
||||||
rlebuflen = 1.05 * xsize + 10;
|
rlebuflen = (int) (1.05 * xsize + 10);
|
||||||
rlebuf = (unsigned char *)malloc(rlebuflen);
|
rlebuf = (unsigned char *)malloc(rlebuflen);
|
||||||
lumbuf = (unsigned char *)malloc(xsize * sizeof(long));
|
lumbuf = (unsigned char *)malloc(xsize * sizeof(long));
|
||||||
if (!starttab || !lengthtab || !rlebuf || !lumbuf) {
|
if (!starttab || !lengthtab || !rlebuf || !lumbuf) {
|
||||||
|
@ -714,7 +714,7 @@ compressrow(lbuf, rlebuf, z, cnt)
|
||||||
iptr -= 8;
|
iptr -= 8;
|
||||||
count = (iptr - sptr) / 4;
|
count = (iptr - sptr) / 4;
|
||||||
while (count) {
|
while (count) {
|
||||||
todo = count > 126 ? 126 : count;
|
todo = count > 126 ? 126 : (short)count;
|
||||||
count -= todo;
|
count -= todo;
|
||||||
*optr++ = 0x80 | todo;
|
*optr++ = 0x80 | todo;
|
||||||
while (todo > 8) {
|
while (todo > 8) {
|
||||||
|
@ -742,10 +742,10 @@ compressrow(lbuf, rlebuf, z, cnt)
|
||||||
iptr += 4;
|
iptr += 4;
|
||||||
count = (iptr - sptr) / 4;
|
count = (iptr - sptr) / 4;
|
||||||
while (count) {
|
while (count) {
|
||||||
todo = count > 126 ? 126 : count;
|
todo = count > 126 ? 126 : (short)count;
|
||||||
count -= todo;
|
count -= todo;
|
||||||
*optr++ = todo;
|
*optr++ = (unsigned char) todo;
|
||||||
*optr++ = cc;
|
*optr++ = (unsigned char) cc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*optr++ = 0;
|
*optr++ = 0;
|
||||||
|
|
|
@ -93,12 +93,12 @@ set_seed(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the next random number in the range [0.0 .. 1.0) */
|
/* Return the next random number in the range [0.0 .. 1.0) */
|
||||||
static float
|
static double
|
||||||
r_random(r)
|
r_random(r)
|
||||||
Rotorobj *r;
|
Rotorobj *r;
|
||||||
{
|
{
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
float val, term;
|
double val, term;
|
||||||
|
|
||||||
x = r->seed[0];
|
x = r->seed[0];
|
||||||
y = r->seed[1];
|
y = r->seed[1];
|
||||||
|
@ -116,12 +116,12 @@ r_random(r)
|
||||||
r->seed[1] = y;
|
r->seed[1] = y;
|
||||||
r->seed[2] = z;
|
r->seed[2] = z;
|
||||||
|
|
||||||
term = (float)(
|
term = (double)(
|
||||||
(((float)x)/(float)30269.0) +
|
(((double)x)/(double)30269.0) +
|
||||||
(((float)y)/(float)30307.0) +
|
(((double)y)/(double)30307.0) +
|
||||||
(((float)z)/(float)30323.0)
|
(((double)z)/(double)30323.0)
|
||||||
);
|
);
|
||||||
val = term - (float)floor((double)term);
|
val = term - (double)floor((double)term);
|
||||||
|
|
||||||
if (val >= 1.0)
|
if (val >= 1.0)
|
||||||
val = 0.0;
|
val = 0.0;
|
||||||
|
@ -134,7 +134,7 @@ r_rand(r, s)
|
||||||
Rotorobj *r;
|
Rotorobj *r;
|
||||||
short s;
|
short s;
|
||||||
{
|
{
|
||||||
return (short)((short)(r_random(r) * (float)s) % s);
|
return (short)((short)(r_random(r) * (double)s) % s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -340,7 +340,7 @@ RTR_init(r)
|
||||||
RTR_e_rotors(r);
|
RTR_e_rotors(r);
|
||||||
RTR_d_rotors(r);
|
RTR_d_rotors(r);
|
||||||
for (i = 0; i < r->rotors; i++) {
|
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))));
|
r->advances[i] = (1+(2*(r_rand(r,r->size/2))));
|
||||||
RTR_permute_rotor(r,
|
RTR_permute_rotor(r,
|
||||||
&(r->e_rotor[(i*r->size)]),
|
&(r->e_rotor[(i*r->size)]),
|
||||||
|
|
|
@ -179,7 +179,7 @@ pack_float(x, p, incr)
|
||||||
p += incr;
|
p += incr;
|
||||||
|
|
||||||
/* Second byte */
|
/* Second byte */
|
||||||
*p = ((e&1)<<7) | (fbits>>16);
|
*p = (char) (((e&1)<<7) | (fbits>>16));
|
||||||
p += incr;
|
p += incr;
|
||||||
|
|
||||||
/* Third byte */
|
/* Third byte */
|
||||||
|
@ -255,7 +255,7 @@ pack_double(x, p, incr)
|
||||||
p += incr;
|
p += incr;
|
||||||
|
|
||||||
/* Second byte */
|
/* Second byte */
|
||||||
*p = ((e&0xF)<<4) | (fhi>>24);
|
*p = (char) (((e&0xF)<<4) | (fhi>>24));
|
||||||
p += incr;
|
p += incr;
|
||||||
|
|
||||||
/* Third byte */
|
/* Third byte */
|
||||||
|
@ -508,7 +508,7 @@ np_byte(p, v, f)
|
||||||
long x;
|
long x;
|
||||||
if (get_long(v, &x) < 0)
|
if (get_long(v, &x) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
*p = x;
|
*p = (char)x;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ np_short(p, v, f)
|
||||||
long x;
|
long x;
|
||||||
if (get_long(v, &x) < 0)
|
if (get_long(v, &x) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
* (short *)p = x;
|
* (short *)p = (short)x;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,7 +700,7 @@ bp_int(p, v, f)
|
||||||
return -1;
|
return -1;
|
||||||
i = f->size;
|
i = f->size;
|
||||||
do {
|
do {
|
||||||
p[--i] = x;
|
p[--i] = (char)x;
|
||||||
x >>= 8;
|
x >>= 8;
|
||||||
} while (i > 0);
|
} while (i > 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -718,7 +718,7 @@ bp_uint(p, v, f)
|
||||||
return -1;
|
return -1;
|
||||||
i = f->size;
|
i = f->size;
|
||||||
do {
|
do {
|
||||||
p[--i] = x;
|
p[--i] = (char)x;
|
||||||
x >>= 8;
|
x >>= 8;
|
||||||
} while (i > 0);
|
} while (i > 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -830,7 +830,7 @@ lp_int(p, v, f)
|
||||||
return -1;
|
return -1;
|
||||||
i = f->size;
|
i = f->size;
|
||||||
do {
|
do {
|
||||||
*p++ = x;
|
*p++ = (char)x;
|
||||||
x >>= 8;
|
x >>= 8;
|
||||||
} while (--i > 0);
|
} while (--i > 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -848,7 +848,7 @@ lp_uint(p, v, f)
|
||||||
return -1;
|
return -1;
|
||||||
i = f->size;
|
i = f->size;
|
||||||
do {
|
do {
|
||||||
*p++ = x;
|
*p++ = (char)x;
|
||||||
x >>= 8;
|
x >>= 8;
|
||||||
} while (--i > 0);
|
} while (--i > 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -84,8 +84,10 @@ extern char *PyMac_StrError PROTO((int));
|
||||||
#endif /* macintosh */
|
#endif /* macintosh */
|
||||||
|
|
||||||
#ifndef __STDC__
|
#ifndef __STDC__
|
||||||
|
#ifndef MS_WINDOWS
|
||||||
extern char *strerror PROTO((int));
|
extern char *strerror PROTO((int));
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Last exception stored by err_setval() */
|
/* Last exception stored by err_setval() */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue