This commit is contained in:
lukem 1997-10-10 13:04:33 +00:00
parent 93b08eefc2
commit 3c70a27d72
5 changed files with 98 additions and 96 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.19 1997/05/07 07:15:35 mycroft Exp $
# $NetBSD: Makefile,v 1.20 1997/10/10 13:04:33 lukem Exp $
# @(#)Makefile 8.2 (Berkeley) 4/19/94
.include <bsd.own.mk> # for INSTALL_OFFENSIVE_FORTUNES
@ -8,7 +8,7 @@ DATFILES= fortunes.dat fortunes2.dat startrek.dat zippy.dat \
fortunes-o fortunes-o.dat fortunes2-o fortunes2-o.dat \
limerick limerick.dat
# TO AVOID INSTALLIND THE POTENTIALLY OFFENSIVE FORTUNES, RUN 'make' with
# TO AVOID INSTALLING THE POTENTIALLY OFFENSIVE FORTUNES, RUN 'make' with
# "INSTALL_OFFENSIVE_FORTUNES=NO", or set "INSTALL_OFFENSIVE_FORTUNES=NO"
# IN bsd.own.mk OR /etc/mk.conf.

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.8 1995/03/23 08:28:36 cgd Exp $
# $NetBSD: Makefile,v 1.9 1997/10/10 13:04:36 lukem Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= fortune
@ -7,5 +7,5 @@ CFLAGS+= -I${.CURDIR}/../strfile
LDADD+= -lcompat
DPADD+= ${LIBCOMPAT}
.include "${.CURDIR}/../../Makefile.inc"
.include "../../Makefile.inc"
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
.\" $NetBSD: fortune.6,v 1.6 1997/07/16 06:59:59 mikel Exp $
.\" $NetBSD: fortune.6,v 1.7 1997/10/10 13:04:37 lukem Exp $
.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -43,7 +43,7 @@
.Nm fortune
.Nd print a random, hopefully interesting, adage
.Sh SYNOPSIS
.Nm fortune
.Nm
.Op Fl aefilosw
.Op Fl m Ar pattern
.Oo
@ -52,7 +52,7 @@
.Oc
.Sh DESCRIPTION
When
.Nm fortune
.Nm
is run with no arguments it prints out a random epigram.
Epigrams are divided into several categories, where each category
is subdivided into those which are potentially offensive and those

View File

@ -1,4 +1,4 @@
/* $NetBSD: fortune.c,v 1.8 1995/03/23 08:28:40 cgd Exp $ */
/* $NetBSD: fortune.c,v 1.9 1997/10/10 13:04:39 lukem Exp $ */
/*-
* Copyright (c) 1986, 1993
@ -36,17 +36,17 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1986, 1993\n\
The Regents of the University of California. All rights reserved.\n";
__COPYRIGHT("@(#) Copyright (c) 1986, 1993\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93";
#else
static char rcsid[] = "$NetBSD: fortune.c,v 1.8 1995/03/23 08:28:40 cgd Exp $";
__RCSID("$NetBSD: fortune.c,v 1.9 1997/10/10 13:04:39 lukem Exp $");
#endif
#endif /* not lint */
@ -144,6 +144,7 @@ void init_prob __P((void));
int is_dir __P((char *));
int is_fortfile __P((char *, char **, char **, int));
int is_off_name __P((char *));
int main __P((int, char *[]));
int max __P((int, int));
FILEDESC *
new_fp __P((void));
@ -185,8 +186,8 @@ char *regcmp(), *regex();
int
main(ac, av)
int ac;
char *av[];
int ac;
char *av[];
{
#ifdef OK_TO_WRITE_DISK
int fd;
@ -239,9 +240,9 @@ char *av[];
void
display(fp)
FILEDESC *fp;
FILEDESC *fp;
{
register char *p, ch;
char *p, ch;
char line[BUFSIZ];
open_fp(fp);
@ -249,7 +250,7 @@ FILEDESC *fp;
for (Fort_len = 0; fgets(line, sizeof line, fp->inf) != NULL &&
!STR_ENDSTRING(line, fp->tbl); Fort_len++) {
if (fp->tbl.str_flags & STR_ROTATED)
for (p = line; ch = *p; ++p)
for (p = line; (ch = *p) != 0; ++p)
if (isupper(ch))
*p = 'A' + (ch - 'A' + 13) % 26;
else if (islower(ch))
@ -266,8 +267,8 @@ FILEDESC *fp;
int
fortlen()
{
register int nchar;
char line[BUFSIZ];
int nchar;
char line[BUFSIZ];
if (!(Fortfile->tbl.str_flags & (STR_RANDOM | STR_ORDERED)))
nchar = (Seekpts[1] - Seekpts[0] <= SLEN);
@ -288,12 +289,12 @@ fortlen()
*/
void
getargs(argc, argv)
register int argc;
register char **argv;
int argc;
char **argv;
{
register int ignore_case;
int ignore_case;
# ifndef NO_REGEX
register char *pat = NULL;
char *pat = NULL;
# endif /* NO_REGEX */
extern char *optarg;
extern int optind;
@ -302,9 +303,9 @@ register char **argv;
ignore_case = FALSE;
# ifdef DEBUG
while ((ch = getopt(argc, argv, "aDefilm:osw")) != EOF)
while ((ch = getopt(argc, argv, "aDefilm:osw")) != -1)
#else
while ((ch = getopt(argc, argv, "aefilm:osw")) != EOF)
while ((ch = getopt(argc, argv, "aefilm:osw")) != -1)
#endif /* DEBUG */
switch(ch) {
case 'a': /* any fortune */
@ -389,11 +390,11 @@ register char **argv;
*/
int
form_file_list(files, file_cnt)
register char **files;
register int file_cnt;
char **files;
int file_cnt;
{
register int i, percent;
register char *sp;
int i, percent;
char *sp;
if (file_cnt == 0)
if (Find_files)
@ -449,17 +450,17 @@ register int file_cnt;
*/
int
add_file(percent, file, dir, head, tail, parent)
int percent;
register char *file;
char *dir;
FILEDESC **head, **tail;
FILEDESC *parent;
int percent;
char *file;
char *dir;
FILEDESC **head, **tail;
FILEDESC *parent;
{
register FILEDESC *fp;
register int fd;
register char *path, *offensive;
register bool was_malloc;
register bool isdir;
FILEDESC *fp;
int fd;
char *path, *offensive;
bool was_malloc;
bool isdir;
if (dir == NULL) {
path = file;
@ -578,7 +579,7 @@ over:
FILEDESC *
new_fp()
{
register FILEDESC *fp;
FILEDESC *fp;
fp = (FILEDESC *) do_malloc(sizeof *fp);
fp->datfd = -1;
@ -602,7 +603,7 @@ new_fp()
*/
char *
off_name(file)
char *file;
char *file;
{
char *new;
@ -616,7 +617,7 @@ char *file;
*/
int
is_off_name(file)
char *file;
char *file;
{
int len;
@ -631,13 +632,13 @@ char *file;
*/
void
all_forts(fp, offensive)
register FILEDESC *fp;
char *offensive;
FILEDESC *fp;
char *offensive;
{
register char *sp;
register FILEDESC *scene, *obscene;
register int fd;
auto char *datfile, *posfile;
char *sp;
FILEDESC *scene, *obscene;
int fd;
auto char *datfile, *posfile;
if (fp->child != NULL) /* this is a directory, not a file */
return;
@ -681,12 +682,12 @@ char *offensive;
*/
int
add_dir(fp)
register FILEDESC *fp;
FILEDESC *fp;
{
register DIR *dir;
register struct dirent *dirent;
auto FILEDESC *tailp;
auto char *name;
DIR *dir;
struct dirent *dirent;
auto FILEDESC *tailp;
auto char *name;
(void) close(fp->fd);
fp->fd = -1;
@ -720,7 +721,7 @@ register FILEDESC *fp;
*/
int
is_dir(file)
char *file;
char *file;
{
auto struct stat sbuf;
@ -739,12 +740,12 @@ char *file;
/* ARGSUSED */
int
is_fortfile(file, datp, posp, check_for_offend)
char *file, **datp, **posp;
int check_for_offend;
char *file, **datp, **posp;
int check_for_offend;
{
register int i;
register char *sp;
register char *datfile;
int i;
char *sp;
char *datfile;
static char *suflist[] = { /* list of "illegal" suffixes" */
"dat", "pos", "c", "h", "p", "i", "f",
"pas", "ftn", "ins.c", "ins,pas",
@ -808,8 +809,8 @@ int check_for_offend;
*/
char *
copy(str, len)
char *str;
unsigned int len;
char *str;
unsigned int len;
{
char *new, *sp;
@ -827,7 +828,7 @@ unsigned int len;
*/
void *
do_malloc(size)
unsigned int size;
unsigned int size;
{
void *new;
@ -844,7 +845,7 @@ unsigned int size;
*/
void
do_free(ptr)
void *ptr;
void *ptr;
{
if (ptr != NULL)
free(ptr);
@ -857,9 +858,10 @@ void *ptr;
void
init_prob()
{
register FILEDESC *fp, *last;
register int percent, num_noprob, frac;
FILEDESC *fp, *last;
int percent, num_noprob, frac;
last = NULL;
/*
* Distribute the residual probability (if any) across all
* files with unspecified probability (i.e., probability of 0)
@ -929,8 +931,8 @@ init_prob()
void
get_fort()
{
register FILEDESC *fp;
register int choice;
FILEDESC *fp;
int choice;
if (File_list->next == NULL || File_list->percent == NO_PROB)
fp = File_list;
@ -991,10 +993,10 @@ get_fort()
*/
FILEDESC *
pick_child(parent)
FILEDESC *parent;
FILEDESC *parent;
{
register FILEDESC *fp;
register int choice;
FILEDESC *fp;
int choice;
if (Equal_probs) {
choice = random() % parent->num_children;
@ -1028,7 +1030,7 @@ FILEDESC *parent;
*/
void
sum_noprobs(fp)
register FILEDESC *fp;
FILEDESC *fp;
{
static bool did_noprobs = FALSE;
@ -1045,7 +1047,7 @@ register FILEDESC *fp;
int
max(i, j)
register int i, j;
int i, j;
{
return (i >= j ? i : j);
}
@ -1056,7 +1058,7 @@ register int i, j;
*/
void
open_fp(fp)
FILEDESC *fp;
FILEDESC *fp;
{
if (fp->inf == NULL && (fp->inf = fdopen(fp->fd, "r")) == NULL) {
perror(fp->path);
@ -1070,7 +1072,7 @@ FILEDESC *fp;
*/
void
open_dat(fp)
FILEDESC *fp;
FILEDESC *fp;
{
if (fp->datfd < 0 && (fp->datfd = open(fp->datfile, 0)) < 0) {
perror(fp->datfile);
@ -1085,7 +1087,7 @@ FILEDESC *fp;
*/
void
get_pos(fp)
FILEDESC *fp;
FILEDESC *fp;
{
#ifdef OK_TO_WRITE_DISK
int fd;
@ -1116,10 +1118,10 @@ FILEDESC *fp;
*/
void
get_tbl(fp)
FILEDESC *fp;
FILEDESC *fp;
{
auto int fd;
register FILEDESC *child;
auto int fd;
FILEDESC *child;
if (fp->read_tbl)
return;
@ -1156,7 +1158,7 @@ FILEDESC *fp;
*/
void
zero_tbl(tp)
register STRFILE *tp;
STRFILE *tp;
{
tp->str_numstr = 0;
tp->str_longlen = 0;
@ -1169,7 +1171,7 @@ register STRFILE *tp;
*/
void
sum_tbl(t1, t2)
register STRFILE *t1, *t2;
STRFILE *t1, *t2;
{
t1->str_numstr += t2->str_numstr;
if (t1->str_longlen < t2->str_longlen)
@ -1196,8 +1198,8 @@ print_file_list()
*/
void
print_list(list, lev)
register FILEDESC *list;
int lev;
FILEDESC *list;
int lev;
{
while (list != NULL) {
fprintf(stderr, "%*s", lev * 4, "");
@ -1222,11 +1224,11 @@ int lev;
*/
char *
conv_pat(orig)
register char *orig;
char *orig;
{
register char *sp;
register unsigned int cnt;
register char *new;
char *sp;
unsigned int cnt;
char *new;
cnt = 1; /* allow for '\0' */
for (sp = orig; *sp != '\0'; sp++)
@ -1283,10 +1285,10 @@ find_matches()
*/
int
maxlen_in_list(list)
FILEDESC *list;
FILEDESC *list;
{
register FILEDESC *fp;
register int len, maxlen;
FILEDESC *fp;
int len, maxlen;
maxlen = 0;
for (fp = list; fp != NULL; fp = fp->next) {
@ -1309,11 +1311,11 @@ FILEDESC *list;
*/
void
matches_in_list(list)
FILEDESC *list;
FILEDESC *list;
{
register char *sp;
register FILEDESC *fp;
int in_file;
char *sp;
FILEDESC *fp;
int in_file;
for (fp = list; fp != NULL; fp = fp->next) {
if (fp->child != NULL) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: strfile.c,v 1.5 1996/10/13 00:01:05 christos Exp $ */
/* $NetBSD: strfile.c,v 1.6 1997/10/10 13:04:42 lukem Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -46,7 +46,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
#else
static char rcsid[] = "$NetBSD: strfile.c,v 1.5 1996/10/13 00:01:05 christos Exp $";
static char rcsid[] = "$NetBSD: strfile.c,v 1.6 1997/10/10 13:04:42 lukem Exp $";
#endif
#endif /* not lint */
@ -266,7 +266,7 @@ char **argv;
extern int optind;
int ch;
while ((ch = getopt(argc, argv, "c:iorsx")) != EOF)
while ((ch = getopt(argc, argv, "c:iorsx")) != -1)
switch(ch) {
case 'c': /* new delimiting char */
Delimch = *optarg;