added minimum boxamount, check for crappy file
authorMart Lubbers <mart@martlubbers.net>
Wed, 20 Apr 2016 18:47:59 +0000 (20:47 +0200)
committerMart Lubbers <mart@martlubbers.net>
Wed, 20 Apr 2016 18:47:59 +0000 (20:47 +0200)
modelchecker/main.c
modelchecker/sokoban.c

index 751a272..06729b1 100644 (file)
@@ -28,7 +28,7 @@ void usage(char *prg)
                "\n"
                "Positional arguments:\n"
                "\tFILE  zero or one sokoban screens\n"
-               "\t              when no file is specified stdin will be used\n", prg);
+               "\t      when no file is specified stdin will be used\n", prg);
 }
 
 BDD subsolve(trans_t *t, BDD new){
@@ -171,6 +171,10 @@ int main(int argc, char **argv)
        } else {
                DPRINT("Processing: %s\n", argv[optind]);
                FILE *currentfile = fopen(argv[optind], "r");
+               if(currentfile == NULL){
+                       printf("File could not be opened\n");
+                       return 2;
+               }
                DPRINT("Opening file\n");
                return solve(currentfile, lurd);
                DPRINT("Closing file\n");
index fd268c0..e5dfd9c 100644 (file)
@@ -126,6 +126,11 @@ sokoban_screen *parse_screen(FILE *stream, bool safe)
                        x++;
                }
        }
+       if(safe == true && boxes == 0){
+               fprintf(stderr, 
+                       "Invalid screen. You need at least 1 box\n");
+               exit(1);
+       }
        if(safe == true && boxes != targets){
                fprintf(stderr, 
                        "Invalid screen. Boxes: %d, Targets: %d\n", boxes, targets);