On Wed, Apr 25, 2018 at 07:19:35PM +0200, Theo Buehler wrote: > Trivial turd polishing, inspired by something similar done in Dragonfly > but using the more familiar idiom for a for loop.
OK > Index: games/tetris/tetris.c > =================================================================== > RCS file: /var/cvs/src/games/tetris/tetris.c,v > retrieving revision 1.32 > diff -u -p -r1.32 tetris.c > --- games/tetris/tetris.c 13 Aug 2017 02:12:16 -0000 1.32 > +++ games/tetris/tetris.c 11 Apr 2018 18:20:35 -0000 > @@ -52,6 +52,8 @@ > #include "screen.h" > #include "tetris.h" > > +#define NUMKEYS 6 > + > cell board[B_SIZE]; > int Rows, Cols; > const struct shape *curshape; > @@ -142,7 +144,6 @@ randshape(void) > tmp = &shapes[classic? tmp->rotc : tmp->rot]; > return (tmp); > } > - > > int > main(int argc, char *argv[]) > @@ -150,7 +151,7 @@ main(int argc, char *argv[]) > int pos, c; > char *keys; > int level = 2; > - char key_write[6][10]; > + char key_write[NUMKEYS][10]; > const char *errstr; > int ch, i, j; > > @@ -171,7 +172,7 @@ main(int argc, char *argv[]) > classic = 1; > break; > case 'k': > - if (strlen(keys = optarg) != 6) > + if (strlen(keys = optarg) != NUMKEYS) > usage(); > break; > case 'l': > @@ -199,8 +200,8 @@ main(int argc, char *argv[]) > > fallrate = 1000000000L / level; > > - for (i = 0; i <= 5; i++) { > - for (j = i+1; j <= 5; j++) { > + for (i = 0; i < NUMKEYS; i++) { > + for (j = i+1; j < NUMKEYS; j++) { > if (keys[i] == keys[j]) > errx(1, "duplicate command keys specified."); > } >