Mail Archives: pgcc/1999/10/12/19:29:39
I forgot to send the file... I can be also a little bit more precise. It
seems that the compiler is confused about register contents. As far as I
can tell it also seems it does not do correct sign extension. It's visible
at the end of the first small loop (the one with r++; i++;).
Loïc
typedef struct {
short x1, y1, x2, y2;
} BoxRec, *BoxPtr;
#define ExchangeRects(a, b) \
{ \
BoxRec t; \
\
t = rects[a]; \
rects[a] = rects[b]; \
rects[b] = t; \
}
void QuickSortRects(BoxPtr rects, int numRects)
{
register int y1;
register int x1;
register int i, j;
register BoxPtr r;
do {
if (numRects == 2) {
if (rects[0].y1 > rects[1].y1 ||
(rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1))
ExchangeRects(0, 1);
return;
}
ExchangeRects(0, numRects >> 1);
y1 = rects[0].y1;
x1 = rects[0].x1;
/* Partition array */
i = 0;
j = numRects;
do
{
r = &(rects[i]);
do
{
r++;
i++;
} while (i != numRects &&
(r->y1 < y1 || (r->y1 == y1 && r->x1 < x1)));
r = &(rects[j]);
do
{
r--;
j--;
} while (y1 < r->y1 || (y1 == r->y1 && x1 < r->x1));
if (i < j)
ExchangeRects(i, j);
} while (i < j);
ExchangeRects(0, j);
if (numRects-j-1 > 1)
QuickSortRects(&rects[j+1], numRects-j-1);
numRects = j;
} while (numRects > 1);
}
- Raw text -