aboutsummaryrefslogtreecommitdiff
path: root/games/fortune
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>2013-02-08 16:10:16 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>2013-02-08 16:10:16 +0000
commitd9a447559bc04121f7c6682e64abe67efa154864 (patch)
treeb2f038222ff8a70f687652441df00d2b564c8abe /games/fortune
parent3cbf5f97aafc2b249c509ee1162c47c9b28e591e (diff)
parentfbda3d5daeeb730a49d025b614b35a32f0319718 (diff)
Notes
Diffstat (limited to 'games/fortune')
-rw-r--r--games/fortune/datfiles/fortunes8
-rw-r--r--games/fortune/datfiles/fortunes-o.real227
-rw-r--r--games/fortune/fortune/fortune.63
-rw-r--r--games/fortune/fortune/fortune.c95
4 files changed, 52 insertions, 281 deletions
diff --git a/games/fortune/datfiles/fortunes b/games/fortune/datfiles/fortunes
index cd476ed7a4b0..c6928a885a12 100644
--- a/games/fortune/datfiles/fortunes
+++ b/games/fortune/datfiles/fortunes
@@ -901,7 +901,7 @@ to add. This will take at least two weeks," he finally said.
"Even that is too much to expect," insisted the manager, "I will be
satisfied if you simply tell me when the program is complete."
The programmer agreed to this.
- Several years slated, the manager retired. On the way to his
+ Several years later, the manager retired. On the way to his
retirement lunch, he discovered the programmer asleep at his terminal.
He had been programming all night.
-- Geoffrey James, "The Tao of Programming"
@@ -7947,7 +7947,7 @@ the same mistake twice without getting nervous.
A well-known friend is a treasure.
%
A well-used door needs no oil on its hinges.
-A swift-flowing steam does no grow stagnant.
+A swift-flowing stream does not grow stagnant.
Neither sound nor thoughts can travel through a vacuum.
Software rots if not used.
@@ -35766,8 +35766,8 @@ the code over again, since I also removed the source.
%
Old age and treachery will overcome youth and skill.
%
-Old age is always fifteen years old than I am.
- -- B. Baruch
+Old age is always fifteen years older than I am.
+ -- Bernard Baruch
%
Old age is the harbor of all ills.
-- Bion
diff --git a/games/fortune/datfiles/fortunes-o.real b/games/fortune/datfiles/fortunes-o.real
index 93fe0ef2bb15..851a439c8c7e 100644
--- a/games/fortune/datfiles/fortunes-o.real
+++ b/games/fortune/datfiles/fortunes-o.real
@@ -11437,233 +11437,6 @@ two new uses for sheep. Meat and wool.
%
Runners do it alone.
%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(1) The greatest threat to the human spirit is liberalism.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(10) Liberalism poisons the soul.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(11) Neither the United States, nor anyone else, "imposes" freedom on
- the people of other nations. Freedom is not an imposition.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(12) Freedom is God-given.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(13) To dictatorships, peace means the absence of opposition.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(14) To free people, peace means the absence of threat.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(15) The Peace Movement in the United States was, whether by accident or
- design, pro-communist.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(16) The collective knowledge and wisdom of seasoned citizens is the
- most valuable, yet untapped, resource our young people have.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(17) The greatest football team in the history of civilization was the
- Pittsburgh Steelers of 1975 through 1980.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(18) There is no such thing as "war atrocities." War is an atrocity.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(19) Regardless of the pain in our memories, nostalgia only reminds us
- of the good times in our past.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(2) The single greatest threat to the free people of the world is posed
- by the heinous idea of centralized government control.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(20) There is a God.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(21) Abortion is wrong.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(22) Morality is not defined by individual choice.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(23) Evolution cannot explain creation.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(24) Feminism was established so that unattractive women could have
- easier access to the mainstream of society.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(25) Love is the only human emotion which cannot be controlled. You
- either do or you don't. You can't fake it. (Except women, and
- thank God they can.)
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(26) The only difference between Mikhail Gorbachev and previous Soviet
- leaders is that he is alive.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(27) Soviet leaders were actually left-wing dictators.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(28) Abraham Lincoln saved this nation.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(29) The Los Angeles Raiders will never be the team they were when they
- called Oakland home.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(3) Peace does not mean the elimination of nuclear weapons.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(30) The United States will again go to war.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(31) To more and more American intellectuals, a victorious United States
- is a sinful United States.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(32) The fact that American intellectuals rue a victorious United States
- is frightening and ominous.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(33) There will always be poor people.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(34) The fact that there will always be poor people is not the fault of
- the rich.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(35) Rather than feel guilty as some do, you should thank God for making
- you an American.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(4) Peace does not mean the absence of war.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(5) War is not obsolete.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(6) Ours is a world governed by the aggressive use of force.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(7) There is only one way to eliminate nuclear weapons. Use them.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(8) Peace cannot be achieved merely by developing an "understanding"
- among peoples.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
-Rush Limbaugh's 35 Undeniable Truths of Life:
-
-(9) Americans opposing America is not always sacred nor courageous ...
- it is sometimes dangerous.
-
- -- "The Limbaugh Letter," Copyright 1992, EFM Publishing, Inc.
-%
Said a dainty young whore named Ms. Meggs,
"The men like to spread my two legs,
Then slip in between,
diff --git a/games/fortune/fortune/fortune.6 b/games/fortune/fortune/fortune.6
index d73274349381..7272fd0d87d1 100644
--- a/games/fortune/fortune/fortune.6
+++ b/games/fortune/fortune/fortune.6
@@ -170,6 +170,9 @@ looks for data files.
If not set it will default to
.Pa /usr/games/fortune .
If none of the directories specified exist, it will print a warning and exit.
+.It Ev FORTUNE_SAVESTATE
+If set, fortune will save some state about what fortune
+it was up to on disk.
.El
.Sh FILES
.Bl -tag -width ".Pa /usr/share/games/fortune/*"
diff --git a/games/fortune/fortune/fortune.c b/games/fortune/fortune/fortune.c
index de85d09d584a..d5ce1b9c80e4 100644
--- a/games/fortune/fortune/fortune.c
+++ b/games/fortune/fortune/fortune.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <locale.h>
#include <regex.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -62,9 +63,8 @@ __FBSDID("$FreeBSD$");
#include "strfile.h"
#include "pathnames.h"
-#define TRUE 1
-#define FALSE 0
-#define bool short
+#define TRUE true
+#define FALSE false
#define MINW 6 /* minimum wait if desired */
#define CPERS 20 /* # of chars for each sec */
@@ -107,8 +107,9 @@ 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
-static bool Debug = FALSE; /* print debug messages */
+static int Debug = 0; /* print debug messages */
#endif
static char *Fortbuf = NULL; /* fortune buffer for -m */
@@ -168,9 +169,10 @@ static regex_t Re_pat;
int
main(int argc, char *argv[])
{
-#ifdef OK_TO_WRITE_DISK
int fd;
-#endif /* OK_TO_WRITE_DISK */
+
+ if (getenv("FORTUNE_SAVESTATE") != NULL)
+ WriteToDisk = true;
(void) setlocale(LC_ALL, "");
@@ -188,26 +190,22 @@ main(int argc, char *argv[])
display(Fortfile);
-#ifdef OK_TO_WRITE_DISK
- if ((fd = creat(Fortfile->posfile, 0666)) < 0) {
- perror(Fortfile->posfile);
- exit(1);
+ if (WriteToDisk) {
+ if ((fd = creat(Fortfile->posfile, 0666)) < 0) {
+ perror(Fortfile->posfile);
+ exit(1);
+ }
+ /*
+ * if we can, we exclusive lock, but since it isn't very
+ * important, we just punt if we don't have easy locking
+ * available.
+ */
+ flock(fd, LOCK_EX);
+ write(fd, (char *) &Fortfile->pos, sizeof Fortfile->pos);
+ if (!Fortfile->was_pos_file)
+ chmod(Fortfile->path, 0666);
+ flock(fd, LOCK_UN);
}
-#ifdef LOCK_EX
- /*
- * if we can, we exclusive lock, but since it isn't very
- * important, we just punt if we don't have easy locking
- * available.
- */
- (void) flock(fd, LOCK_EX);
-#endif /* LOCK_EX */
- write(fd, (char *) &Fortfile->pos, sizeof Fortfile->pos);
- if (!Fortfile->was_pos_file)
- (void) chmod(Fortfile->path, 0666);
-#ifdef LOCK_EX
- (void) flock(fd, LOCK_UN);
-#endif /* LOCK_EX */
-#endif /* OK_TO_WRITE_DISK */
if (Wait) {
if (Fort_len == 0)
(void) fortlen();
@@ -585,9 +583,8 @@ over:
fp->next = *head;
*head = fp;
}
-#ifdef OK_TO_WRITE_DISK
- fp->was_pos_file = (access(fp->posfile, W_OK) >= 0);
-#endif /* OK_TO_WRITE_DISK */
+ if (WriteToDisk)
+ fp->was_pos_file = (access(fp->posfile, W_OK) >= 0);
return (TRUE);
}
@@ -689,10 +686,9 @@ all_forts(FILEDESC *fp, char *offensive)
obscene->name = ++sp;
obscene->datfile = datfile;
obscene->posfile = posfile;
- obscene->read_tbl = FALSE;
-#ifdef OK_TO_WRITE_DISK
- obscene->was_pos_file = (access(obscene->posfile, W_OK) >= 0);
-#endif /* OK_TO_WRITE_DISK */
+ obscene->read_tbl = false;
+ if (WriteToDisk)
+ obscene->was_pos_file = (access(obscene->posfile, W_OK) >= 0);
}
/*
@@ -822,12 +818,13 @@ is_fortfile(const char *file, char **datp, char **posp, int check_for_offend)
else
free(datfile);
if (posp != NULL) {
-#ifdef OK_TO_WRITE_DISK
- *posp = copy(file, (unsigned int) (strlen(file) + 4)); /* +4 for ".dat" */
- (void) strcat(*posp, ".pos");
-#else
- *posp = NULL;
-#endif /* OK_TO_WRITE_DISK */
+ if (WriteToDisk) {
+ *posp = copy(file, (unsigned int) (strlen(file) + 4)); /* +4 for ".dat" */
+ strcat(*posp, ".pos");
+ }
+ else {
+ *posp = NULL;
+ }
}
DPRINTF(2, (stderr, "TRUE\n"));
@@ -1108,23 +1105,21 @@ open_dat(FILEDESC *fp)
static void
get_pos(FILEDESC *fp)
{
-#ifdef OK_TO_WRITE_DISK
int fd;
-#endif /* OK_TO_WRITE_DISK */
assert(fp->read_tbl);
if (fp->pos == POS_UNKNOWN) {
-#ifdef OK_TO_WRITE_DISK
- if ((fd = open(fp->posfile, O_RDONLY)) < 0 ||
- read(fd, &fp->pos, sizeof fp->pos) != sizeof fp->pos)
+ if (WriteToDisk) {
+ if ((fd = open(fp->posfile, O_RDONLY)) < 0 ||
+ read(fd, &fp->pos, sizeof fp->pos) != sizeof fp->pos)
+ fp->pos = arc4random_uniform(fp->tbl.str_numstr);
+ else if (fp->pos >= fp->tbl.str_numstr)
+ fp->pos %= fp->tbl.str_numstr;
+ if (fd >= 0)
+ close(fd);
+ }
+ else
fp->pos = arc4random_uniform(fp->tbl.str_numstr);
- else if (fp->pos >= fp->tbl.str_numstr)
- fp->pos %= fp->tbl.str_numstr;
- if (fd >= 0)
- (void) close(fd);
-#else
- fp->pos = arc4random_uniform(fp->tbl.str_numstr);
-#endif /* OK_TO_WRITE_DISK */
}
if (++(fp->pos) >= fp->tbl.str_numstr)
fp->pos -= fp->tbl.str_numstr;