[Midnightbsd-cvs] src [11905] trunk/games/fortune/fortune/fortune.c: sync with freebsd.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Jul 17 21:06:31 EDT 2018


Revision: 11905
          http://svnweb.midnightbsd.org/src/?rev=11905
Author:   laffer1
Date:     2018-07-17 21:06:31 -0400 (Tue, 17 Jul 2018)
Log Message:
-----------
sync with freebsd.

Modified Paths:
--------------
    trunk/games/fortune/fortune/Makefile
    trunk/games/fortune/fortune/fortune.6
    trunk/games/fortune/fortune/fortune.c

Property Changed:
----------------
    trunk/games/fortune/fortune/fortune.6

Modified: trunk/games/fortune/fortune/Makefile
===================================================================
--- trunk/games/fortune/fortune/Makefile	2018-07-18 01:06:11 UTC (rev 11904)
+++ trunk/games/fortune/fortune/Makefile	2018-07-18 01:06:31 UTC (rev 11905)
@@ -1,5 +1,6 @@
+# $MidnightBSD$
 #	@(#)Makefile	8.1 (Berkeley) 5/31/93
-# $MidnightBSD$
+# $FreeBSD: stable/10/games/fortune/fortune/Makefile 203923 2010-02-15 14:32:00Z uqs $
 
 PROG=	fortune
 MAN=	fortune.6

Modified: trunk/games/fortune/fortune/fortune.6
===================================================================
--- trunk/games/fortune/fortune/fortune.6	2018-07-18 01:06:11 UTC (rev 11904)
+++ trunk/games/fortune/fortune/fortune.6	2018-07-18 01:06:31 UTC (rev 11905)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 1985, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -29,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	@(#)fortune.6	8.3 (Berkeley) 4/19/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/games/fortune/fortune/fortune.6 242577 2012-11-04 15:15:47Z eadler $
 .\"
 .Dd November 7, 2007
 .Dt FORTUNE 6


Property changes on: trunk/games/fortune/fortune/fortune.6
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/games/fortune/fortune/fortune.c
===================================================================
--- trunk/games/fortune/fortune/fortune.c	2018-07-18 01:06:11 UTC (rev 11904)
+++ trunk/games/fortune/fortune/fortune.c	2018-07-18 01:06:31 UTC (rev 11905)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1986, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -42,7 +43,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/games/fortune/fortune/fortune.c 261995 2014-02-16 20:13:18Z marcel $");
 
 #include <sys/stat.h>
 #include <sys/endian.h>
@@ -97,74 +98,72 @@
 	struct fd	*next, *prev;
 } FILEDESC;
 
-bool	Found_one;			/* did we find a match? */
-bool	Find_files	= FALSE;	/* just find a list of proper fortune files */
-bool	Fortunes_only   = FALSE;	/* check only "fortunes" files */
-bool	Wait		= FALSE;	/* wait desired after fortune */
-bool	Short_only	= FALSE;	/* short fortune desired */
-bool	Long_only	= FALSE;	/* long fortune desired */
-bool	Offend		= FALSE;	/* offensive fortunes only */
-bool	All_forts	= FALSE;	/* any fortune allowed */
-bool	Equal_probs	= FALSE;	/* scatter un-allocted prob equally */
-bool	Match		= FALSE;	/* dump fortunes matching a pattern */
+static bool	Found_one;		/* did we find a match? */
+static bool	Find_files = FALSE;	/* just find a list of proper fortune files */
+static bool	Fortunes_only = FALSE;	/* check only "fortunes" files */
+static bool	Wait = FALSE;		/* wait desired after fortune */
+static bool	Short_only = FALSE;	/* short fortune desired */
+static bool	Long_only = FALSE;	/* long fortune desired */
+static bool	Offend = FALSE;		/* offensive fortunes only */
+static bool	All_forts = FALSE;	/* any fortune allowed */
+static bool	Equal_probs = FALSE;	/* scatter un-allocted prob equally */
+static bool	Match = FALSE;		/* dump fortunes matching a pattern */
 static bool	WriteToDisk = false;	/* use files on disk to save state */
 #ifdef DEBUG
-int	Debug = FALSE;			/* print debug messages */
+static int	Debug = 0;		/* print debug messages */
 #endif
 
-char	*Fortbuf = NULL;			/* fortune buffer for -m */
+static char	*Fortbuf = NULL;	/* fortune buffer for -m */
 
-int	Fort_len = 0;
+static int	Fort_len = 0;
 
-off_t	Seekpts[2];                     /* seek pointers to fortunes */
+static off_t	Seekpts[2];		/* seek pointers to fortunes */
 
-FILEDESC	*File_list = NULL,	/* Head of file list */
+static FILEDESC	*File_list = NULL,	/* Head of file list */
 		*File_tail = NULL;	/* Tail of file list */
-FILEDESC	*Fortfile;		/* Fortune file to use */
+static FILEDESC	*Fortfile;		/* Fortune file to use */
 
-STRFILE		Noprob_tbl;		/* sum of data for all no prob files */
+static STRFILE	Noprob_tbl;		/* sum of data for all no prob files */
 
-const char	*Fortune_path;
-char	**Fortune_path_arr;
+static const char *Fortune_path;
+static char	**Fortune_path_arr;
 
-int	 add_dir(FILEDESC *);
-int	 add_file(int, const char *, const char *, FILEDESC **, FILEDESC **,
-	    FILEDESC *);
-void	 all_forts(FILEDESC *, char *);
-char	*copy(const char *, u_int);
-void	 display(FILEDESC *);
-void	 do_free(void *);
-void	*do_malloc(u_int);
-int	 form_file_list(char **, int);
-int	 fortlen(void);
-void	 get_fort(void);
-void	 get_pos(FILEDESC *);
-void	 get_tbl(FILEDESC *);
-void	 getargs(int, char *[]);
-void	 getpath(void);
-void	 init_prob(void);
-int	 is_dir(const char *);
-int	 is_fortfile(const char *, char **, char **, int);
-int	 is_off_name(const char *);
-int	 max(int, int);
-FILEDESC *
-	 new_fp(void);
-char	*off_name(const char *);
-void	 open_dat(FILEDESC *);
-void	 open_fp(FILEDESC *);
-FILEDESC *
-	 pick_child(FILEDESC *);
-void	 print_file_list(void);
-void	 print_list(FILEDESC *, int);
-void	 sum_noprobs(FILEDESC *);
-void	 sum_tbl(STRFILE *, STRFILE *);
-void	 usage(void);
-void	 zero_tbl(STRFILE *);
+static int	 add_dir(FILEDESC *);
+static int	 add_file(int, const char *, const char *, FILEDESC **,
+		     FILEDESC **, FILEDESC *);
+static void	 all_forts(FILEDESC *, char *);
+static char	*copy(const char *, u_int);
+static void	 display(FILEDESC *);
+static void	 do_free(void *);
+static void	*do_malloc(u_int);
+static int	 form_file_list(char **, int);
+static int	 fortlen(void);
+static void	 get_fort(void);
+static void	 get_pos(FILEDESC *);
+static void	 get_tbl(FILEDESC *);
+static void	 getargs(int, char *[]);
+static void	 getpath(void);
+static void	 init_prob(void);
+static int	 is_dir(const char *);
+static int	 is_fortfile(const char *, char **, char **, int);
+static int	 is_off_name(const char *);
+static int	 max(int, int);
+static FILEDESC *new_fp(void);
+static char	*off_name(const char *);
+static void	 open_dat(FILEDESC *);
+static void	 open_fp(FILEDESC *);
+static FILEDESC *pick_child(FILEDESC *);
+static void	 print_file_list(void);
+static void	 print_list(FILEDESC *, int);
+static void	 sum_noprobs(FILEDESC *);
+static void	 sum_tbl(STRFILE *, STRFILE *);
+static void	 usage(void);
+static void	 zero_tbl(STRFILE *);
 
-char	*conv_pat(char *);
-int	 find_matches(void);
-void	 matches_in_list(FILEDESC *);
-int	 maxlen_in_list(FILEDESC *);
+static char	*conv_pat(char *);
+static int	 find_matches(void);
+static void	 matches_in_list(FILEDESC *);
+static int	 maxlen_in_list(FILEDESC *);
 
 static regex_t Re_pat;
 
@@ -217,7 +216,7 @@
 	exit(0);
 }
 
-void
+static void
 display(FILEDESC *fp)
 {
 	char   *p;
@@ -250,7 +249,7 @@
  * fortlen:
  *	Return the length of the fortune.
  */
-int
+static int
 fortlen(void)
 {
 	int	nchar;
@@ -274,7 +273,7 @@
 /*
  *	This routine evaluates the arguments on the command line
  */
-void
+static void
 getargs(int argc, char *argv[])
 {
 	int	ignore_case;
@@ -360,7 +359,7 @@
  * form_file_list:
  *	Form the file list from the file specifications.
  */
-int
+static int
 form_file_list(char **files, int file_cnt)
 {
 	int	i, percent;
@@ -454,7 +453,7 @@
  * add_file:
  *	Add a file to the file list.
  */
-int
+static int
 add_file(int percent, const char *file, const char *dir, FILEDESC **head,
     FILEDESC **tail, FILEDESC *parent)
 {
@@ -488,7 +487,7 @@
 		if (Offend) {
 			if (was_malloc)
 				free(tpath);
-			path = offensive;
+			path = tpath = offensive;
 			offensive = NULL;
 			was_malloc = TRUE;
 			DPRINTF(1, (stderr, "\ttrying \"%s\"\n", path));
@@ -510,7 +509,7 @@
 		if (All_forts && offensive != NULL) {
 			if (was_malloc)
 				free(tpath);
-			path = offensive;
+			path = tpath = offensive;
 			offensive = NULL;
 			was_malloc = TRUE;
 			DPRINTF(1, (stderr, "\ttrying \"%s\"\n", path));
@@ -595,7 +594,7 @@
  * new_fp:
  *	Return a pointer to an initialized new FILEDESC.
  */
-FILEDESC *
+static FILEDESC *
 new_fp(void)
 {
 	FILEDESC	*fp;
@@ -621,7 +620,7 @@
  * off_name:
  *	Return a pointer to the offensive version of a file of this name.
  */
-char *
+static char *
 off_name(const char *file)
 {
 	char	*new;
@@ -635,7 +634,7 @@
  * is_off_name:
  *	Is the file an offensive-style name?
  */
-int
+static int
 is_off_name(const char *file)
 {
 	int	len;
@@ -650,7 +649,7 @@
  *	Modify a FILEDESC element to be the parent of two children if
  *	there are two children to be a parent of.
  */
-void
+static void
 all_forts(FILEDESC *fp, char *offensive)
 {
 	char		*sp;
@@ -697,7 +696,7 @@
  * add_dir:
  *	Add the contents of an entire directory.
  */
-int
+static int
 add_dir(FILEDESC *fp)
 {
 	DIR		*dir;
@@ -736,7 +735,7 @@
  * is_dir:
  *	Return TRUE if the file is a directory, FALSE otherwise.
  */
-int
+static int
 is_dir(const char *file)
 {
 	struct stat	sbuf;
@@ -755,7 +754,7 @@
  *	suffixes, as contained in suflist[], are ruled out.
  */
 /* ARGSUSED */
-int
+static int
 is_fortfile(const char *file, char **datp, char **posp, int check_for_offend)
 {
 	int	i;
@@ -808,10 +807,6 @@
 	strcat(datfile, ".dat");
 	if (access(datfile, R_OK) < 0) {
 		DPRINTF(2, (stderr, "FALSE (no readable \".dat\" file)\n"));
-#ifdef DEBUG
-		if (Debug < 2)
-			DPRINTF(0, (stderr, "Warning: file \"%s\" unreadable\n", datfile));
-#endif
 		free(datfile);
 		return (FALSE);
 	}
@@ -837,7 +832,7 @@
  * copy:
  *	Return a malloc()'ed copy of the string
  */
-char *
+static char *
 copy(const char *str, unsigned int len)
 {
 	char *new, *sp;
@@ -855,7 +850,7 @@
  * do_malloc:
  *	Do a malloc, checking for NULL return.
  */
-void *
+static void *
 do_malloc(unsigned int size)
 {
 	void *new;
@@ -872,7 +867,7 @@
  * do_free:
  *	Free malloc'ed space, if any.
  */
-void
+static void
 do_free(void *ptr)
 {
 	if (ptr != NULL)
@@ -883,7 +878,7 @@
  * init_prob:
  *	Initialize the fortune probabilities.
  */
-void
+static void
 init_prob(void)
 {
 	FILEDESC       *fp, *last = NULL;
@@ -952,7 +947,7 @@
  * get_fort:
  *	Get the fortune data file's seek pointer for the next fortune.
  */
-void
+static void
 get_fort(void)
 {
 	FILEDESC	*fp;
@@ -1015,7 +1010,7 @@
  * pick_child
  *	Pick a child from a chosen parent.
  */
-FILEDESC *
+static FILEDESC *
 pick_child(FILEDESC *parent)
 {
 	FILEDESC	*fp;
@@ -1051,7 +1046,7 @@
  * sum_noprobs:
  *	Sum up all the noprob probabilities, starting with fp.
  */
-void
+static void
 sum_noprobs(FILEDESC *fp)
 {
 	static bool	did_noprobs = FALSE;
@@ -1067,7 +1062,7 @@
 	did_noprobs = TRUE;
 }
 
-int
+static int
 max(int i, int j)
 {
 	return (i >= j ? i : j);
@@ -1077,7 +1072,7 @@
  * open_fp:
  *	Assocatiate a FILE * with the given FILEDESC.
  */
-void
+static void
 open_fp(FILEDESC *fp)
 {
 	if (fp->inf == NULL && (fp->inf = fdopen(fp->fd, "r")) == NULL) {
@@ -1090,7 +1085,7 @@
  * open_dat:
  *	Open up the dat file if we need to.
  */
-void
+static void
 open_dat(FILEDESC *fp)
 {
 	if (fp->datfd < 0 && (fp->datfd = open(fp->datfile, O_RDONLY)) < 0) {
@@ -1104,7 +1099,7 @@
  *	Get the position from the pos file, if there is one.  If not,
  *	return a random number.
  */
-void
+static void
 get_pos(FILEDESC *fp)
 {
 	int	fd;
@@ -1132,7 +1127,7 @@
  * get_tbl:
  *	Get the tbl data file the datfile.
  */
-void
+static void
 get_tbl(FILEDESC *fp)
 {
 	int		fd;
@@ -1171,7 +1166,7 @@
  * zero_tbl:
  *	Zero out the fields we care about in a tbl structure.
  */
-void
+static void
 zero_tbl(STRFILE *tp)
 {
 	tp->str_numstr = 0;
@@ -1183,7 +1178,7 @@
  * sum_tbl:
  *	Merge the tbl data of t2 into t1.
  */
-void
+static void
 sum_tbl(STRFILE *t1, STRFILE *t2)
 {
 	t1->str_numstr += t2->str_numstr;
@@ -1199,7 +1194,7 @@
  * print_file_list:
  *	Print out the file list
  */
-void
+static void
 print_file_list(void)
 {
 	print_list(File_list, 0);
@@ -1209,7 +1204,7 @@
  * print_list:
  *	Print out the actual list, recursively.
  */
-void
+static void
 print_list(FILEDESC *list, int lev)
 {
 	while (list != NULL) {
@@ -1232,7 +1227,7 @@
  * conv_pat:
  *	Convert the pattern to an ignore-case equivalent.
  */
-char *
+static char *
 conv_pat(char *orig)
 {
 	char		*sp;
@@ -1275,7 +1270,7 @@
  * find_matches:
  *	Find all the fortunes which match the pattern we've been given.
  */
-int
+static int
 find_matches(void)
 {
 	Fort_len = maxlen_in_list(File_list);
@@ -1293,7 +1288,7 @@
  * maxlen_in_list
  *	Return the maximum fortune len in the file list.
  */
-int
+static int
 maxlen_in_list(FILEDESC *list)
 {
 	FILEDESC	*fp;
@@ -1319,7 +1314,7 @@
  * matches_in_list
  *	Print out the matches from the files in the list.
  */
-void
+static void
 matches_in_list(FILEDESC *list)
 {
 	char           *sp, *p;
@@ -1370,7 +1365,7 @@
 	}
 }
 
-void
+static void
 usage(void)
 {
 	(void) fprintf(stderr, "fortune [-a");
@@ -1389,7 +1384,7 @@
  *	if not set, use the compiled in FORTDIR.
  */
 
-void
+static void
 getpath(void)
 {
 	int	nstr, foundenv;



More information about the Midnightbsd-cvs mailing list