This is a discussion on Re: floating point exception in games/boggle/mkdict (+ typo) within the lucky.openbsd.tech forums, part of the OpenBSD category; --> Hi again, I have used some unneeded curly brackets, this diff also writes both if-statements into one: --- games/boggle/mkdict/mkdict.c~ ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi again, I have used some unneeded curly brackets, this diff also writes both if-statements into one: --- games/boggle/mkdict/mkdict.c~ Sun Apr 2 12:13:55 2006 +++ games/boggle/mkdict/mkdict.c Sun Apr 2 12:14:36 2006 @@ -51,12 +51,13 @@ * Filter out words that: * 1) Are not completely made up of lower case letters * 2) Contain a 'q' not immediately followed by a 'u' - * 3) Are less that 3 characters long + * 3) Are less than 3 characters long * 4) Are greater than MAXWORDLEN characters long */ #include <ctype.h> #include <err.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -74,8 +75,8 @@ prev = 0; current = 1; buf[prev][0] = '\0'; - if (argc == 2) - n = atoi(argv[1]); + if (argc == 2 && (n = strtonum(argv[1], 1, INT_MAX, NULL)) == 0) + errx(1, "invalid value"); for (nwords = 1; fgets(buf[current], MAXWORDLEN + 1, stdin) != NULL; ++nwords) { Tobias Stoeckmann |