View | Details | Raw Unified | Return to bug 237768
Collapse All | Expand All

(-)usr.bin/fortune/fortune/fortune.c (-31 / +10 lines)
Lines 99-105 Link Here
99
99
100
static bool	Found_one;		/* did we find a match? */
100
static bool	Found_one;		/* did we find a match? */
101
static bool	Find_files = FALSE;	/* just find a list of proper fortune files */
101
static bool	Find_files = FALSE;	/* just find a list of proper fortune files */
102
static bool	Fortunes_only = FALSE;	/* check only "fortunes" files */
103
static bool	Wait = FALSE;		/* wait desired after fortune */
102
static bool	Wait = FALSE;		/* wait desired after fortune */
104
static bool	Short_only = FALSE;	/* short fortune desired */
103
static bool	Short_only = FALSE;	/* short fortune desired */
105
static bool	Long_only = FALSE;	/* long fortune desired */
104
static bool	Long_only = FALSE;	/* long fortune desired */
Lines 366-398 Link Here
366
	char	**pstr;
365
	char	**pstr;
367
366
368
	if (file_cnt == 0) {
367
	if (file_cnt == 0) {
369
		if (Find_files) {
368
		pstr = Fortune_path_arr;
370
			Fortunes_only = TRUE;
369
		i = 0;
371
			pstr = Fortune_path_arr;
370
		while (*pstr) {
372
			i = 0;
371
			i += add_file(NO_PROB, *pstr++, NULL,
373
			while (*pstr) {
372
				      &File_list, &File_tail, NULL);
374
				i += add_file(NO_PROB, *pstr++, NULL,
375
					      &File_list, &File_tail, NULL);
376
			}
377
			Fortunes_only = FALSE;
378
			if (!i) {
379
				fprintf(stderr, "No fortunes found in %s.\n",
380
				    Fortune_path);
381
			}
382
			return (i != 0);
383
		} else {
384
			pstr = Fortune_path_arr;
385
			i = 0;
386
			while (*pstr) {
387
				i += add_file(NO_PROB, "fortunes", *pstr++,
388
					      &File_list, &File_tail, NULL);
389
			}
390
			if (!i) {
391
				fprintf(stderr, "No fortunes found in %s.\n",
392
				    Fortune_path);
393
			}
394
			return (i != 0);
395
		}
373
		}
374
		if (!i) {
375
			fprintf(stderr, "No fortunes found in %s.\n",
376
			    Fortune_path);
377
		}
378
		return (i != 0);
396
	}
379
	}
397
	for (i = 0; i < file_cnt; i++) {
380
	for (i = 0; i < file_cnt; i++) {
398
		percent = NO_PROB;
381
		percent = NO_PROB;
Lines 789-798 Link Here
789
		DPRINTF(2, (stderr, "FALSE (file starts with '.')\n"));
772
		DPRINTF(2, (stderr, "FALSE (file starts with '.')\n"));
790
		return (FALSE);
773
		return (FALSE);
791
	}
774
	}
792
	if (Fortunes_only && strncmp(sp, "fortunes", 8) != 0) {
793
		DPRINTF(2, (stderr, "FALSE (check fortunes only)\n"));
794
		return (FALSE);
795
	}
796
	if ((sp = strrchr(sp, '.')) != NULL) {
775
	if ((sp = strrchr(sp, '.')) != NULL) {
797
		sp++;
776
		sp++;
798
		for (i = 0; suflist[i] != NULL; i++)
777
		for (i = 0; suflist[i] != NULL; i++)

Return to bug 237768