34 |
|
char *progname; |
35 |
|
|
36 |
|
short ordertab[4][2] = { |
37 |
< |
{0,XDECR}, {XDECR,XDECR|YDECR}, {XDECR|YDECR,YDECR}, {YDECR,0} |
37 |
> |
{0,0}, {XDECR,XDECR|YDECR}, {XDECR|YDECR,YDECR}, {YDECR,XDECR} |
38 |
|
}; |
39 |
|
|
40 |
+ |
|
41 |
|
static int neworder(void); |
42 |
|
static void rotatecw(FILE *fp); |
43 |
|
static void rotateccw(FILE *fp); |
47 |
|
static int |
48 |
|
neworder(void) /* return corrected order */ |
49 |
|
{ |
50 |
+ |
static short ordercw[8]; |
51 |
|
register int i; |
52 |
|
|
53 |
|
if (correctorder) |
54 |
|
return(order); |
55 |
< |
for (i = 4; i--; ) |
56 |
< |
if ((order&~YMAJOR) == ordertab[i][ccw]) |
57 |
< |
return(ordertab[i][1-ccw] | ((order&YMAJOR)^YMAJOR)); |
55 |
> |
if (!ordercw[0]) { |
56 |
> |
ordercw[YMAJOR|YDECR] = 0; |
57 |
> |
ordercw[0] = YMAJOR|XDECR; |
58 |
> |
ordercw[YMAJOR|XDECR] = XDECR|YDECR; |
59 |
> |
ordercw[XDECR|YDECR] = YMAJOR|YDECR; |
60 |
> |
ordercw[YMAJOR|XDECR|YDECR] = XDECR; |
61 |
> |
ordercw[XDECR] = YMAJOR; |
62 |
> |
ordercw[YMAJOR] = YDECR; |
63 |
> |
ordercw[YDECR] = YMAJOR|XDECR|YDECR; |
64 |
> |
} |
65 |
> |
if (!ccw) |
66 |
> |
return(ordercw[order]); |
67 |
> |
for (i = 8; i--; ) |
68 |
> |
if (ordercw[i] == order) |
69 |
> |
return(i); |
70 |
|
fputs("Order botch!\n", stderr); |
71 |
|
exit(2); |
72 |
|
} |