More games cleanups

看板DFBSD_submit作者時間21年前 (2005/03/22 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
------=_Part_4614_11390894.1111427550184 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Here are patches to make 5 more of the games WARNS 6 clean. There should be no operational changes. Mostly constifying strings, changing declarations, removing (void) casts. -Craig -- ----------------------------------------------------------------------- Craig Dooley <xlnxminusx@gmail.com> ------=_Part_4614_11390894.1111427550184 Content-Type: text/plain; name="arithmetic-warns6.patch.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="arithmetic-warns6.patch.txt" Index: games/arithmetic/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/dcvs/src/games/arithmetic/Makefile,v retrieving revision 1.2 diff -u -r1.2 Makefile --- games/arithmetic/Makefile=0917 Jun 2003 04:25:22 -0000=091.2 +++ games/arithmetic/Makefile=0917 Mar 2005 09:45:53 -0000 @@ -5,5 +5,6 @@ PROG=3D=09arithmetic MAN=3D=09arithmetic.6 HIDEGAME=3Dhidegame +WARNS?=3D 6 =20 .include <bsd.prog.mk> Index: games/arithmetic/arithmetic.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/dcvs/src/games/arithmetic/arithmetic.c,v retrieving revision 1.3 diff -u -r1.3 arithmetic.c --- games/arithmetic/arithmetic.c=0912 Nov 2003 14:53:52 -0000=091.3 +++ games/arithmetic/arithmetic.c=0917 Mar 2005 09:45:37 -0000 @@ -100,11 +100,7 @@ * bound is 10. After every NQUESTS questions, statistics on the performa= nce * so far are printed. */ -int -main(argc, argv) -=09int argc; -=09char **argv; -{ +int main(int argc, char **argv) { =09int ch, cnt; =20 =09/* Revoke setgid privileges */ @@ -117,8 +113,7 @@ =20 =09=09=09for (p =3D keys =3D optarg; *p; ++p) =09=09=09=09if (!index(keylist, *p)) { -=09=09=09=09=09(void)fprintf(stderr, -=09=09=09=09=09 "arithmetic: unknown key.\n"); +=09=09=09=09=09fprintf(stderr, "arithmetic: unknown key.\n"); =09=09=09=09=09exit(1); =09=09=09=09} =09=09=09nkeys =3D p - optarg; @@ -126,8 +121,7 @@ =09=09} =09=09case 'r': =09=09=09if ((rangemax =3D atoi(optarg)) <=3D 0) { -=09=09=09=09(void)fprintf(stderr, -=09=09=09=09 "arithmetic: invalid range.\n"); +=09=09=09=09fprintf(stderr, "arithmetic: invalid range.\n"); =09=09=09=09exit(1); =09=09=09} =09=09=09break; @@ -141,7 +135,7 @@ =09/* Seed the random-number generator. */ =09srandomdev(); =20 -=09(void)signal(SIGINT, intr); +=09signal(SIGINT, intr); =20 =09/* Now ask the questions. */ =09for (;;) { @@ -154,26 +148,22 @@ } =20 /* Handle interrupt character. Print score and exit. */ -void -intr(sig) -=09int sig; -{ +void intr(__unused int sig) { =09showstats(); =09exit(0); } =20 /* Print score. Original `arithmetic' had a delay after printing it. */ -void -showstats() -{ +void showstats(void) { =09if (nright + nwrong > 0) { -=09=09(void)printf("\n\nRights %d; Wrongs %d; Score %d%%", +=09=09printf("\n\nRights %d; Wrongs %d; Score %d%%", =09=09 nright, nwrong, (int)(100L * nright / (nright + nwrong))); -=09=09if (nright > 0) -=09(void)printf("\nTotal time %ld seconds; %.1f seconds per problem\n\n", +=09=09if (nright > 0) { +=09=09=09printf("\nTotal time %ld seconds; %.1f seconds per problem\n\n", =09=09=09 (long)qtime, (float)qtime / nright); +=09=09} =09} -=09(void)printf("\n"); +=09printf("\n"); } =20 /* @@ -184,9 +174,7 @@ * answer causes the numbers in the problem to be penalised, so that they = are * more likely to appear in subsequent problems. */ -int -problem() -{ +int problem(void) { =09char *p; =09time_t start, finish; =09int left, op, right, result; @@ -227,9 +215,9 @@ =09if (result < 0 || left < 0) =09=09goto retry; =20 -=09(void)printf("%d %c %d =3D ", left, op, right); -=09(void)fflush(stdout); -=09(void)time(&start); +=09printf("%d %c %d =3D ", left, op, right); +=09fflush(stdout); +=09time(&start); =20 =09/* =09 * Keep looping until the correct answer is given, or until EOF or @@ -237,21 +225,21 @@ =09 */ =09for (;;) { =09=09if (!fgets(line, sizeof(line), stdin)) { -=09=09=09(void)printf("\n"); +=09=09=09printf("\n"); =09=09=09return(EOF); =09=09} =09=09for (p =3D line; *p && isspace(*p); ++p); =09=09if (!isdigit(*p)) { -=09=09=09(void)printf("Please type a number.\n"); +=09=09=09printf("Please type a number.\n"); =09=09=09continue; =09=09} =09=09if (atoi(p) =3D=3D result) { -=09=09=09(void)printf("Right!\n"); +=09=09=09printf("Right!\n"); =09=09=09++nright; =09=09=09break; =09=09} =09=09/* Wrong answer; penalise and ask again. */ -=09=09(void)printf("What?\n"); +=09=09printf("What?\n"); =09=09++nwrong; =09=09penalise(right, op, 1); =09=09if (op =3D=3D 'x' || op =3D=3D '+') @@ -267,7 +255,7 @@ =09 * the time you are not charged for a partially elapsed second at the =09 * end. =09 */ -=09(void)time(&finish); +=09time(&finish); =09qtime +=3D finish - start; =09return(0); } @@ -299,10 +287,7 @@ * operand number `operand' (0 or 1). If we run out of memory, we just * forget about the penalty (how likely is this, anyway?). */ -void -penalise(value, op, operand) -=09int value, op, operand; -{ +void penalise(int value, int op, int operand) { =09struct penalty *p; =20 =09op =3D opnum(op); @@ -320,10 +305,7 @@ * as a value, or represents a position in the penalty list. If the latte= r, * we find the corresponding value and return that, decreasing its penalty= .. */ -int -getrandom(maxval, op, operand) -=09int maxval, op, operand; -{ +int getrandom(int maxval, int op, int operand) { =09int value; =09struct penalty **pp, *p; =20 @@ -348,7 +330,7 @@ =09=09=09penalty[op][operand]--; =09=09=09if (--(p->penalty) <=3D 0) { =09=09=09=09p =3D p->next; -=09=09=09=09(void)free((char *)*pp); +=09=09=09=09free((char *)*pp); =09=09=09=09*pp =3D p; =09=09=09} =09=09=09return(value); @@ -360,20 +342,17 @@ =09 * correspond to the actual sum of penalties in the list. Provide an =09 * obscure message. =09 */ -=09(void)fprintf(stderr, "arithmetic: bug: inconsistent penalties\n"); +=09fprintf(stderr, "arithmetic: bug: inconsistent penalties\n"); =09exit(1); =09/* NOTREACHED */ } =20 /* Return an index for the character op, which is one of [+-x/]. */ -int -opnum(op) -=09int op; -{ +int opnum(int op) { =09char *p; =20 =09if (op =3D=3D 0 || (p =3D index(keylist, op)) =3D=3D NULL) { -=09=09(void)fprintf(stderr, +=09=09fprintf(stderr, =09=09 "arithmetic: bug: op %c not in keylist %s\n", op, keylist); =09=09exit(1); =09} @@ -381,9 +360,7 @@ } =20 /* Print usage message and quit. */ -static void -usage() -{ -=09(void)fprintf(stderr, "usage: arithmetic [-o +-x/] [-r range]\n"); +static void usage(void) { +=09fprintf(stderr, "usage: arithmetic [-o +-x/] [-r range]\n"); =09exit(1); } ------=_Part_4614_11390894.1111427550184 Content-Type: text/plain; name="fish-warns6.patch.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fish-warns6.patch.txt" Index: games/fish/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/dcvs/src/games/fish/Makefile,v retrieving revision 1.2 diff -u -r1.2 Makefile --- games/fish/Makefile=0917 Jun 2003 04:25:23 -0000=091.2 +++ games/fish/Makefile=0917 Mar 2005 10:10:41 -0000 @@ -6,5 +6,5 @@ FILES=3D=09fish.instr MAN=3D=09fish.6 HIDEGAME=3Dhidegame - +WARNS?=3D=096 .include <bsd.prog.mk> Index: games/fish/fish.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/dcvs/src/games/fish/fish.c,v retrieving revision 1.3 diff -u -r1.3 fish.c --- games/fish/fish.c=0912 Nov 2003 14:53:53 -0000=091.3 +++ games/fish/fish.c=0917 Mar 2005 10:15:49 -0000 @@ -58,11 +58,11 @@ #define=09COMPUTER=090 #define=09OTHER(a)=09(1 - (a)) =20 -char *cards[] =3D { +const char *cards[] =3D { =09"A", "2", "3", "4", "5", "6", "7", =09"8", "9", "10", "J", "Q", "K", NULL, }; -#define=09PRC(card)=09(void)printf(" %s", cards[card]) +#define=09PRC(card)=09printf(" %s", cards[card]) =20 int promode; int asked[RANKS], comphand[RANKS], deck[RANKS]; @@ -84,11 +84,7 @@ void=09usage (void); int =09usermove (void); =20 -int -main(argc, argv) -=09int argc; -=09char **argv; -{ +int main(int argc, char **argv) { =09int ch, move; =20 =09while ((ch =3D getopt(argc, argv, "p")) !=3D -1) @@ -98,7 +94,7 @@ =09=09=09break; =09=09case '?': =09=09default: -=09=09=09(void)fprintf(stderr, "usage: fish [-p]\n"); +=09=09=09fprintf(stderr, "usage: fish [-p]\n"); =09=09=09exit(1); =09=09} =20 @@ -108,11 +104,11 @@ =20 =09if (nrandom(2) =3D=3D 1) { =09=09printplayer(COMPUTER); -=09=09(void)printf("get to start.\n"); +=09=09printf("get to start.\n"); =09=09goto istart; =09} =09printplayer(USER); -=09(void)printf("get to start.\n"); +=09printf("get to start.\n"); =20 =09for (;;) { =09=09move =3D usermove(); @@ -137,34 +133,32 @@ =09return(EXIT_FAILURE); } =20 -int -usermove() -{ +int usermove(void) { =09int n; -=09char **p; +=09char const**p; =09char buf[256]; =20 -=09(void)printf("\nYour hand is:"); +=09printf("\nYour hand is:"); =09printhand(userhand); =20 =09for (;;) { -=09=09(void)printf("You ask me for: "); -=09=09(void)fflush(stdout); +=09=09printf("You ask me for: "); +=09=09fflush(stdout); =09=09if (fgets(buf, sizeof(buf), stdin) =3D=3D NULL) =09=09=09exit(0); =09=09if (buf[0] =3D=3D '\0') =09=09=09continue; =09=09if (buf[0] =3D=3D '\n') { -=09=09=09(void)printf("%d cards in my hand, %d in the pool.\n", +=09=09=09printf("%d cards in my hand, %d in the pool.\n", =09=09=09 countcards(comphand), countcards(deck)); -=09=09=09(void)printf("My books:"); -=09=09=09(void)countbooks(comphand); +=09=09=09printf("My books:"); +=09=09=09countbooks(comphand); =09=09=09continue; =09=09} =09=09buf[strlen(buf) - 1] =3D '\0'; =09=09if (!strcasecmp(buf, "p") && !promode) { =09=09=09promode =3D 1; -=09=09=09(void)printf("Entering pro mode.\n"); +=09=09=09printf("Entering pro mode.\n"); =09=09=09continue; =09=09} =09=09if (!strcasecmp(buf, "quit")) @@ -173,7 +167,7 @@ =09=09=09if (!strcasecmp(*p, buf)) =09=09=09=09break; =09=09if (!*p) { -=09=09=09(void)printf("I don't understand!\n"); +=09=09=09printf("I don't understand!\n"); =09=09=09continue; =09=09} =09=09n =3D p - cards; @@ -182,19 +176,17 @@ =09=09=09return(n); =09=09} =09=09if (nrandom(3) =3D=3D 1) -=09=09=09(void)printf("You don't have any of those!\n"); +=09=09=09printf("You don't have any of those!\n"); =09=09else -=09=09=09(void)printf("You don't have any %s's!\n", cards[n]); +=09=09=09printf("You don't have any %s's!\n", cards[n]); =09=09if (nrandom(4) =3D=3D 1) -=09=09=09(void)printf("No cheating!\n"); -=09=09(void)printf("Guess again.\n"); +=09=09=09printf("No cheating!\n"); +=09=09printf("Guess again.\n"); =09} =09/* NOTREACHED */ } =20 -int -compmove() -{ +int compmove(void) { =09static int lmove; =20 =09if (promode) @@ -206,13 +198,11 @@ =09} =09asked[lmove] =3D 1; =20 -=09(void)printf("I ask you for: %s.\n", cards[lmove]); +=09printf("I ask you for: %s.\n", cards[lmove]); =09return(lmove); } =20 -int -promove() -{ +int promove(void) { =09int i, max; =20 =09for (i =3D 0; i < RANKS; ++i) @@ -249,11 +239,7 @@ =09/* NOTREACHED */ } =20 -int -drawcard(player, hand) -=09int player; -=09int *hand; -{ +int drawcard(int player, int *hand) { =09int card; =20 =09while (deck[card =3D nrandom(RANKS)] =3D=3D 0); @@ -261,41 +247,33 @@ =09--deck[card]; =09if (player =3D=3D USER || hand[card] =3D=3D CARDS) { =09=09printplayer(player); -=09=09(void)printf("drew %s", cards[card]); +=09=09printf("drew %s", cards[card]); =09=09if (hand[card] =3D=3D CARDS) { -=09=09=09(void)printf(" and made a book of %s's!\n", +=09=09=09printf(" and made a book of %s's!\n", =09=09=09 cards[card]); =09=09=09chkwinner(player, hand); =09=09} else -=09=09=09(void)printf(".\n"); +=09=09=09printf(".\n"); =09} =09return(card); } =20 -int -gofish(askedfor, player, hand) -=09int askedfor, player; -=09int *hand; -{ +int gofish(int askedfor, int player, int *hand) { =09printplayer(OTHER(player)); -=09(void)printf("say \"GO FISH!\"\n"); +=09printf("say \"GO FISH!\"\n"); =09if (askedfor =3D=3D drawcard(player, hand)) { =09=09printplayer(player); -=09=09(void)printf("drew the guess!\n"); +=09=09printf("drew the guess!\n"); =09=09printplayer(player); -=09=09(void)printf("get to ask again!\n"); +=09=09printf("get to ask again!\n"); =09=09return(1); =09} =09return(0); } =20 -void -goodmove(player, move, hand, opphand) -=09int player, move; -=09int *hand, *opphand; -{ +void goodmove(int player, int move, int *hand, int *opphand) { =09printplayer(OTHER(player)); -=09(void)printf("have %d %s%s.\n", +=09printf("have %d %s%s.\n", =09 opphand[move], cards[move], opphand[move] =3D=3D 1 ? "": "'s"); =20 =09hand[move] +=3D opphand[move]; @@ -303,64 +281,54 @@ =20 =09if (hand[move] =3D=3D CARDS) { =09=09printplayer(player); -=09=09(void)printf("made a book of %s's!\n", cards[move]); +=09=09printf("made a book of %s's!\n", cards[move]); =09=09chkwinner(player, hand); =09} =20 =09chkwinner(OTHER(player), opphand); =20 =09printplayer(player); -=09(void)printf("get another guess!\n"); +=09printf("get another guess!\n"); } =20 -void -chkwinner(player, hand) -=09int player; -=09int *hand; -{ +void chkwinner(int player, int *hand) { =09int cb, i, ub; =20 =09for (i =3D 0; i < RANKS; ++i) =09=09if (hand[i] > 0 && hand[i] < CARDS) =09=09=09return; =09printplayer(player); -=09(void)printf("don't have any more cards!\n"); -=09(void)printf("My books:"); +=09printf("don't have any more cards!\n"); +=09printf("My books:"); =09cb =3D countbooks(comphand); -=09(void)printf("Your books:"); +=09printf("Your books:"); =09ub =3D countbooks(userhand); -=09(void)printf("\nI have %d, you have %d.\n", cb, ub); +=09printf("\nI have %d, you have %d.\n", cb, ub); =09if (ub > cb) { -=09=09(void)printf("\nYou win!!!\n"); +=09=09printf("\nYou win!!!\n"); =09=09if (nrandom(1024) =3D=3D 0723) -=09=09=09(void)printf("Cheater, cheater, pumpkin eater!\n"); +=09=09=09printf("Cheater, cheater, pumpkin eater!\n"); =09} else if (cb > ub) { -=09=09(void)printf("\nI win!!!\n"); +=09=09printf("\nI win!!!\n"); =09=09if (nrandom(1024) =3D=3D 0723) -=09=09=09(void)printf("Hah! Stupid peasant!\n"); +=09=09=09printf("Hah! Stupid peasant!\n"); =09} else -=09=09(void)printf("\nTie!\n"); +=09=09printf("\nTie!\n"); =09exit(0); } =20 -void -printplayer(player) -=09int player; -{ +void printplayer(int player) { =09switch (player) { =09case COMPUTER: -=09=09(void)printf("I "); +=09=09printf("I "); =09=09break; =09case USER: -=09=09(void)printf("You "); +=09=09printf("You "); =09=09break; =09} } =20 -void -printhand(hand) -=09int *hand; -{ +void printhand(int *hand) { =09int book, i, j; =20 =09for (book =3D i =3D 0; i < RANKS; i++) @@ -370,18 +338,15 @@ =09=09else =09=09=09++book; =09if (book) { -=09=09(void)printf(" + Book%s of", book > 1 ? "s" : ""); +=09=09printf(" + Book%s of", book > 1 ? "s" : ""); =09=09for (i =3D 0; i < RANKS; i++) =09=09=09if (hand[i] =3D=3D CARDS) =09=09=09=09PRC(i); =09} -=09(void)putchar('\n'); +=09putchar('\n'); } =20 -int -countcards(hand) -=09int *hand; -{ +int countcards(int *hand) { =09int i, count; =20 =09for (count =3D i =3D 0; i < RANKS; i++) @@ -389,10 +354,7 @@ =09return(count); } =20 -int -countbooks(hand) -=09int *hand; -{ +int countbooks(int *hand) { =09int i, count; =20 =09for (count =3D i =3D 0; i < RANKS; i++) @@ -401,14 +363,12 @@ =09=09=09PRC(i); =09=09} =09if (!count) -=09=09(void)printf(" none"); -=09(void)putchar('\n'); +=09=09printf(" none"); +=09putchar('\n'); =09return(count); } =20 -void -init() -{ +void init(void) { =09int i, rank; =20 =09for (i =3D 0; i < RANKS; ++i) @@ -425,35 +385,27 @@ =09} } =20 -int -nrandom(n) -=09int n; -{ - +int nrandom(int n) { =09return((int)random() % n); } =20 -void -instructions() -{ +void instructions(void) { =09int input; =09char buf[1024]; =20 -=09(void)printf("Would you like instructions (y or n)? "); +=09printf("Would you like instructions (y or n)? "); =09input =3D getchar(); =09while (getchar() !=3D '\n'); =09if (input !=3D 'y') =09=09return; =20 -=09(void)sprintf(buf, "%s %s", _PATH_MORE, _PATH_INSTR); -=09(void)system(buf); -=09(void)printf("Hit return to continue...\n"); +=09sprintf(buf, "%s %s", _PATH_MORE, _PATH_INSTR); +=09system(buf); +=09printf("Hit return to continue...\n"); =09while ((input =3D getchar()) !=3D EOF && input !=3D '\n'); } =20 -void -usage() -{ -=09(void)fprintf(stderr, "usage: fish [-p]\n"); +void usage(void) { +=09fprintf(stderr, "usage: fish [-p]\n"); =09exit(1); } ------=_Part_4614_11390894.1111427550184 Content-Type: text/plain; name="morse-warns6.patch.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="morse-warns6.patch.txt" Index: games/morse/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/dcvs/src/games/morse/Makefile,v retrieving revision 1.2 diff -u -r1.2 Makefile --- games/morse/Makefile=0917 Jun 2003 04:25:24 -0000=091.2 +++ games/morse/Makefile=0917 Mar 2005 10:18:51 -0000 @@ -4,6 +4,7 @@ =20 PROG=3D=09morse MAN=3D=09morse.6 +WARNS?=3D=096 =20 .if ${MACHINE_ARCH} =3D=3D "i386" CFLAGS +=3D -DSPEAKER=3D\"/dev/speaker\" Index: games/morse/morse.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/dcvs/src/games/morse/morse.c,v retrieving revision 1.2 diff -u -r1.2 morse.c --- games/morse/morse.c=0917 Jun 2003 04:25:24 -0000=091.2 +++ games/morse/morse.c=0917 Mar 2005 10:19:29 -0000 @@ -59,8 +59,8 @@ #endif =20 struct morsetab { -=09char inchar; -=09char *morse; +=09const char=09inchar; +=09const char=09*morse; }; =20 static const struct morsetab mtab[] =3D { ------=_Part_4614_11390894.1111427550184 Content-Type: text/plain; name="piano-warns6.patch.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="piano-warns6.patch.txt" Index: games/piano/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/dcvs/src/games/piano/Makefile,v retrieving revision 1.2 diff -u -r1.2 Makefile --- games/piano/Makefile=0917 Jun 2003 04:25:24 -0000=091.2 +++ games/piano/Makefile=0917 Mar 2005 09:58:50 -0000 @@ -6,5 +6,6 @@ MAN=3D=09piano.6 DPADD=3D=09${LIBCURSES} ${LIBTERMCAP} LDADD=3D=09-lcurses -ltermcap +WARNS?=3D=096 =20 .include <bsd.prog.mk> Index: games/piano/piano.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/dcvs/src/games/piano/piano.c,v retrieving revision 1.2 diff -u -r1.2 piano.c --- games/piano/piano.c=0917 Jun 2003 04:25:24 -0000=091.2 +++ games/piano/piano.c=0917 Mar 2005 10:08:55 -0000 @@ -14,9 +14,9 @@ =20 char *myname; int verbose; -static char *initcmd =3D "t160 o1 l16 ml"; +static const char *initcmd =3D "t160 o1 l16 ml"; =20 -static char usage_msg[] =3D +static const char usage_msg[] =3D =09"simple keyboard player V0.8086\n" =09"usage: %s [-v][-i str]\n" =09"\t-i str defaults 't160 o1 l16 ml'\n" @@ -28,10 +28,10 @@ =20 struct kdef_t { =09int ch; -=09char *str; +=09const char *str; }; =20 -static char *kstr[256]; +static char const *kstr[256]; =20 static struct kdef_t kdef[] =3D { =09/* white key */ @@ -69,9 +69,7 @@ =09{ '\0', NULL } }; =20 -static int -init_kstr(void) -{ +static int init_kstr(void) { =09struct kdef_t *mv =3D kdef; =09while (mv->str !=3D NULL) { =09=09kstr[mv->ch] =3D mv->str; @@ -80,21 +78,17 @@ =09return 0; }/* init_kstr */ =20 -static int -fdputs(const char *s, int fd, int echo) -{ +static int fdputs(const char *s, int fd, int output) { =09int err, len =3D strlen(s); =09write(fd, s, len); =09err =3D write(fd, "\n", 1); -=09if (echo) { +=09if (output) { =09=09fputs(s, stdout); =09} =09return err; }/* fdputs */ =20 -static int -outspkr(const char *s) -{ +static int outspkr(const char *s) { =09int err =3D -1, fd =3D open("/dev/speaker", O_WRONLY); =09if (fd >=3D 0) { =09=09fdputs(initcmd, fd, 0); @@ -104,9 +98,7 @@ =09return err; }/* outspkr */ =20 -static int -nain(void) -{ +static int nain(void) { =09int ch; =09initscr(); =09noecho(); @@ -134,9 +126,7 @@ =09return 0; }/* nain */ =20 -int -main(int argc, char *argv[]) -{ +int main(int argc, char **argv) { =09int ch, ex, show_usage =3D 0; =09myname =3D argv[0]; =09while ((ch =3D getopt(argc, argv, "-vi:")) !=3D -1) { ------=_Part_4614_11390894.1111427550184 Content-Type: text/plain; name="pig-warns6.patch.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pig-warns6.patch.txt" Index: games/pig/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/dcvs/src/games/pig/Makefile,v retrieving revision 1.2 diff -u -r1.2 Makefile --- games/pig/Makefile=0917 Jun 2003 04:25:24 -0000=091.2 +++ games/pig/Makefile=0917 Mar 2005 09:48:04 -0000 @@ -4,5 +4,6 @@ =20 PROG=3D=09pig MAN=3D=09pig.6 +WARNS?=3D=096 =20 .include <bsd.prog.mk> Index: games/pig/pig.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/dcvs/src/games/pig/pig.c,v retrieving revision 1.3 diff -u -r1.3 pig.c --- games/pig/pig.c=0912 Nov 2003 14:53:53 -0000=091.3 +++ games/pig/pig.c=0917 Mar 2005 09:57:34 -0000 @@ -47,11 +47,7 @@ void pigout (char *, int); void usage (void); =20 -int -main(argc, argv) -=09int argc; -=09char *argv[]; -{ +int main(int argc, char **argv) { =09int len; =09int ch; =09char buf[1024]; @@ -67,8 +63,8 @@ =20 =09for (len =3D 0; (ch =3D getchar()) !=3D EOF;) { =09=09if (isalpha(ch)) { -=09=09=09if (len >=3D sizeof(buf)) { -=09=09=09=09(void)fprintf(stderr, "pig: ate too much!\n"); +=09=09=09if ((unsigned int)len >=3D sizeof(buf)) { +=09=09=09=09fprintf(stderr, "pig: ate too much!\n"); =09=09=09=09exit(1); =09=09=09} =09=09=09buf[len++] =3D ch; @@ -78,16 +74,12 @@ =09=09=09pigout(buf, len); =09=09=09len =3D 0; =09=09} -=09=09(void)putchar(ch); +=09=09putchar(ch); =09} =09exit(0); } =20 -void -pigout(buf, len) -=09char *buf; -=09int len; -{ +void pigout(char *buf, int len) { =09int ch, start; =09int olen; =20 @@ -96,7 +88,7 @@ =09 * as a vowel if it appears first. =09 */ =09if (index("aeiouAEIOU", buf[0]) !=3D NULL) { -=09=09(void)printf("%.*sway", len, buf); +=09=09printf("%.*sway", len, buf); =09=09return; =09} =20 @@ -111,12 +103,10 @@ =09=09 (buf[start] =3D=3D 'u' || buf[start] =3D=3D 'U')) =09=09=09buf[len++] =3D buf[start++]; =09} -=09(void)printf("%.*say", olen, buf + start); +=09printf("%.*say", olen, buf + start); } =20 -void -usage() -{ -=09(void)fprintf(stderr, "usage: pig\n"); +void usage(void) { +=09fprintf(stderr, "usage: pig\n"); =09exit(1); } ------=_Part_4614_11390894.1111427550184--
文章代碼(AID): #12FmmL00 (DFBSD_submit)