Index | Thread | Search

From:
Nir Lichtman <nir@lichtman.org>
Subject:
Minor fixes in Fortune game
To:
tech@openbsd.org
Date:
Sat, 5 Oct 2024 09:46:10 +0000

Download raw body.

Thread
diff --git games/fortune/fortune/fortune.c games/fortune/fortune/fortune.c
index 652422839..9a84b23cd 100644
--- games/fortune/fortune/fortune.c
+++ games/fortune/fortune/fortune.c
@@ -163,8 +163,11 @@ main(int ac, char *av[])
 
 	init_prob();
 	if ((Short_only && minlen_in_list(File_list) > SLEN) ||
-	    (Long_only && maxlen_in_list(File_list) <= SLEN))
+	    (Long_only && maxlen_in_list(File_list) <= SLEN)) {
+		(void)fprintf(stderr,
+			"no fortunes matching length constraint found\n");
 		return 1;
+	}
 
 	do {
 		get_fort();
@@ -251,12 +254,10 @@ fortlen(void)
 void
 getargs(int argc, char *argv[])
 {
-	int	ignore_case;
+	bool	ignore_case = false;
 	char	*pat = NULL;
 	int ch;
 
-	ignore_case = 0;
-
 #ifdef DEBUG
 	while ((ch = getopt(argc, argv, "aDefhilm:osw")) != -1)
 #else
@@ -296,7 +297,7 @@ getargs(int argc, char *argv[])
 			pat = optarg;
 			break;
 		case 'i':			/* case-insensitive match */
-			ignore_case = 1;
+			ignore_case = true;
 			break;
 		case 'h':
 		default:
@@ -1116,6 +1117,7 @@ find_matches(void)
 
 	Found_one = false;
 	matches_in_list(File_list);
+	free(Fortbuf);
 	return Found_one;
 }