From: Mart Lubbers Date: Wed, 20 Apr 2016 18:47:59 +0000 (+0200) Subject: added minimum boxamount, check for crappy file X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=c652648c47a5f1206951314a15e540f75cdbcf73;p=mc1516pa.git added minimum boxamount, check for crappy file --- diff --git a/modelchecker/main.c b/modelchecker/main.c index 751a272..06729b1 100644 --- a/modelchecker/main.c +++ b/modelchecker/main.c @@ -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"); diff --git a/modelchecker/sokoban.c b/modelchecker/sokoban.c index fd268c0..e5dfd9c 100644 --- a/modelchecker/sokoban.c +++ b/modelchecker/sokoban.c @@ -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);