--- ray/src/px/protate.c 2003/05/15 05:13:35 2.8 +++ ray/src/px/protate.c 2004/04/30 20:29:24 2.10 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: protate.c,v 2.8 2003/05/15 05:13:35 greg Exp $"; +static const char RCSid[] = "$Id: protate.c,v 2.10 2004/04/30 20:29:24 greg Exp $"; #endif /* * prot.c - program to rotate picture file 90 degrees clockwise. @@ -34,28 +34,48 @@ int nrows; /* number of rows output at once */ char *progname; short ordertab[4][2] = { - {0,XDECR}, {XDECR,XDECR|YDECR}, {XDECR|YDECR,YDECR}, {YDECR,0} + {0,0}, {XDECR,XDECR|YDECR}, {XDECR|YDECR,YDECR}, {YDECR,XDECR} }; -int -neworder() /* return corrected order */ +static int neworder(void); +static void rotatecw(FILE *fp); +static void rotateccw(FILE *fp); + + + +static int +neworder(void) /* return corrected order */ { + static short ordercw[8]; register int i; if (correctorder) return(order); - for (i = 4; i--; ) - if ((order&~YMAJOR) == ordertab[i][ccw]) - return(ordertab[i][1-ccw] | ((order&YMAJOR)^YMAJOR)); + if (!ordercw[0]) { + ordercw[YMAJOR|YDECR] = 0; + ordercw[0] = YMAJOR|XDECR; + ordercw[YMAJOR|XDECR] = XDECR|YDECR; + ordercw[XDECR|YDECR] = YMAJOR|YDECR; + ordercw[YMAJOR|XDECR|YDECR] = XDECR; + ordercw[XDECR] = YMAJOR; + ordercw[YMAJOR] = YDECR; + ordercw[YDECR] = YMAJOR|XDECR|YDECR; + } + if (!ccw) + return(ordercw[order]); + for (i = 8; i--; ) + if (ordercw[i] == order) + return(i); fputs("Order botch!\n", stderr); exit(2); } - -main(argc, argv) -int argc; -char *argv[]; +int +main( + int argc, + char *argv[] +) { static char picfmt[LPICFMT+1] = PICFMT; int rval; @@ -118,8 +138,10 @@ userr: } -rotatecw(fp) /* rotate picture clockwise */ -FILE *fp; +static void +rotatecw( /* rotate picture clockwise */ + FILE *fp +) { register COLR *inln; register int xoff, inx, iny; @@ -154,8 +176,10 @@ FILE *fp; } -rotateccw(fp) /* rotate picture counter-clockwise */ -FILE *fp; +static void +rotateccw( /* rotate picture counter-clockwise */ + FILE *fp +) { register COLR *inln; register int xoff, inx, iny;