From: Eric S. Raymond Date: Thu, 13 Apr 1995 18:44:23 +0000 (+0000) Subject: Bounds fix. X-Git-Tag: 2.0~16 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=ac7977bb39a824d6630b775b58254c00c7d5f235;p=deal.git Bounds fix. --- diff --git a/deal.c b/deal.c index f926411..0b1661b 100644 --- a/deal.c +++ b/deal.c @@ -62,12 +62,15 @@ main(argc, argv) (void) printf(" c = columns in the report (optional)\n"); } else { special = atoi(argv[1]); + total = atoi(argv[2]); if (total < special) { (void) printf("Can't have more specials than total cards!\n"); exit(-1); - } - + } else if (total <= BASEHAND) { + (void) printf("All specials would be in the initial hand!\n"); + exit(-1); + } if (total - BASEHAND < TURNS_DEFAULT) turns = total - BASEHAND; @@ -84,10 +87,10 @@ main(argc, argv) columns = special + 1; if (argc >= 5) columns = atoi(argv[4]); - if (columns > special) { + if (columns > special + 1) { (void) printf("using %d columns because can only have ",special+1); (void) printf("0 to %d specials\n",special); - columns = special+1; + columns = special + 1; } (void) printf("%d specials out of %d total; %d turns, %d columns\n",