]> thyrsus.com Git - deal.git/commitdiff
Bounds fix.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 13 Apr 1995 18:44:23 +0000 (18:44 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 13 Apr 1995 18:44:23 +0000 (18:44 +0000)
deal.c

diff --git a/deal.c b/deal.c
index f926411a0d179751da5ff4780d103ada2cc09d01..0b1661b9c3ae20de47827065c2d382f0d60ca37e 100644 (file)
--- 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",