Hi,
just did a check-out and had trouble compiling with the Microsoft Visual
C++ Toolkit 2003 compiler (version 7.1).
Mainly variables not declared at the top of a block, and a couple of
casts in 'transform.c'.
Also found a minor bug in pygame.event.set_blocked() when type is None,
in 'event.c'.
Whilst I was in there (and looking at the SDL code) I noticed that there
is no range checking on the event values in Pygame or SDL. To prevent
inadvertent trampling of memory, I've added some range checking code
which raises a ValueError().
Patch against latest SVN attached.
Hope it's useful,
regards,
John.
PS the reformatted code looks much better :-)
Index: src/transform.c
===
--- src/transform.c (revision 1052)
+++ src/transform.c (working copy)
@@ -987,13 +987,13 @@
}
else
{
+int xfrac = 0x1 - xcounter;
/* write out a destination pixel */
*dstpix++ = (Uint8) (((accumulate[0] + ((srcpix[0] * xcounter)
16)) * xrecip) 16);
*dstpix++ = (Uint8) (((accumulate[1] + ((srcpix[1] * xcounter)
16)) * xrecip) 16);
*dstpix++ = (Uint8) (((accumulate[2] + ((srcpix[2] * xcounter)
16)) * xrecip) 16);
*dstpix++ = (Uint8) (((accumulate[3] + ((srcpix[3] * xcounter)
16)) * xrecip) 16);
/* reload the accumulator with the remainder of this pixel */
-int xfrac = 0x1 - xcounter;
accumulate[0] = (Uint16) ((*srcpix++ * xfrac) 16);
accumulate[1] = (Uint16) ((*srcpix++ * xfrac) 16);
accumulate[2] = (Uint16) ((*srcpix++ * xfrac) 16);
@@ -1180,15 +1180,15 @@
int srcdiff = srcpitch - (width * 4);
int dstdiff = dstpitch - (width * 4);
int x, y;
+int yspace = 0x1 * srcheight / dstheight; /* must be 1 */
+int yrecip = (int) ((long long) 0x1 / yspace);
+int ycounter = yspace;
/* allocate and clear a memory area for storing the accumulator line */
templine = (Uint16 *) malloc(dstpitch * 2);
if (templine == NULL) return;
memset(templine, 0, dstpitch * 2);
-int yspace = 0x1 * srcheight / dstheight; /* must be 1 */
-int yrecip = (int) ((long long) 0x1 / yspace);
-int ycounter = yspace;
for (y = 0; y srcheight; y++)
{
Uint16 *accumulate = templine;
@@ -1205,6 +1205,7 @@
}
else
{
+int yfrac = 0x1 - ycounter;
/* write out a destination line */
for (x = 0; x width; x++)
{
@@ -1217,7 +1218,6 @@
/* reload the accumulator with the remainder of this line */
accumulate = templine;
srcpix -= 4 * width;
-int yfrac = 0x1 - ycounter;
for (x = 0; x width; x++)
{
*accumulate++ = (Uint16) ((*srcpix++ * yfrac) 16);
@@ -1241,15 +1241,15 @@
int srcdiff = srcpitch - (width * 4);
int dstdiff = dstpitch - (width * 4);
int x, y;
+int yspace = 0x4000 * srcheight / dstheight; /* must be 1 */
+int yrecip = (int) ((long long) 0x04000 / yspace);
+long long One64 = 0x4000400040004000ULL;
/* allocate and clear a memory area for storing the accumulator line */
templine = (Uint16 *) malloc(dstpitch * 2);
if (templine == NULL) return;
memset(templine, 0, dstpitch * 2);
-int yspace = 0x4000 * srcheight / dstheight; /* must be 1 */
-int yrecip = (int) ((long long) 0x04000 / yspace);
-long long One64 = 0x4000400040004000ULL;
#if defined(__GNUC__) defined(__x86_64__)
long long srcdiff64 = srcdiff;
long long dstdiff64 = dstdiff;
@@ -1439,11 +1439,11 @@
int dstdiff = dstpitch - (dstwidth * 4);
int *xidx0, *xmult0, *xmult1;
int x, y;
+int factorwidth = 4;
/* Allocate memory for factors */
xidx0 = malloc(dstwidth * 4);
if (xidx0 == NULL) return;
-int factorwidth = 4;
xmult0 = (int *) malloc(dstwidth * factorwidth);
xmult1 = (int *) malloc(dstwidth * factorwidth);
if (xmult0 == NULL || xmult1 == NULL)
@@ -1490,11 +1490,11 @@
int dstdiff = dstpitch - (dstwidth * 4);
int *xidx0, *xmult0, *xmult1;
int x, y;
+int factorwidth = 8;
/* Allocate memory for factors */
xidx0 = malloc(dstwidth * 4);
if (xidx0 == NULL) return;
-int factorwidth = 8;
xmult0 = (int *) malloc(dstwidth * factorwidth);
xmult1 = (int *) malloc(dstwidth * factorwidth);
if (xmult0 == NULL || xmult1 == NULL)
@@ -1507,9 +1507,9 @@
/* Create multiplier factors and starting indices and put them in arrays */
for (x = 0; x dstwidth; x++)
{
-xidx0[x] = x * (srcwidth - 1) / dstwidth;
int xm1 = 0x100 * ((x * (srcwidth - 1)) % dstwidth) / dstwidth;
int xm0 = 0x100 - xm1;
+xidx0[x] = x *