Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!burl!codas!killer!billw From: billw@killer.UUCP Newsgroups: comp.sources.bugs Subject: Berkeley fortune program on SysV Message-ID: <2048@killer.UUCP> Date: Mon, 9-Nov-87 17:38:39 EST Article-I.D.: killer.2048 Posted: Mon Nov 9 17:38:39 1987 Date-Received: Thu, 12-Nov-87 03:44:30 EST Reply-To: billw@killer.UUCP (Bill Wisner) Distribution: world Organization: HASA Lines: 71 [ You can feed this entire article to patch ... ] After a long, long delay I finally decided to get the Berkeley fortune program from volume 1 of comp.sources.games running on killer. The program claimed to run fine on SysV with appropriate defines, but it didn't quite work out that way. The fixes are, of course, included in this article. First of all, it seems that due to a doubled #include, is scanned twice and all the typedefs repeated. Our compiler didn't like that. Quickie fix is to remove the #include from strfile.h. Thanks to Steve Parker for catching this one. *** orig/strfile.h Mon Nov 9 15:19:54 1987 --- strfile.h Sun Nov 8 12:35:04 1987 *************** *** 3,10 # define __STRFILE__ - # include - # define MAXDELIMS 3 /* --- 3,8 ----- # define __STRFILE__ # define MAXDELIMS 3 /* So, I have the fortune program compiled and the fortunes database properly assembled and installed, so I eagerly type fortune to see what gem of wisdom I will get. Well, it wasn't quite what I expected: Floating exception - core dumped After a bit of mucking about with debuggers and the like, it became apparent that due to inadequate variable checks, an operation identical to "0 % 0" was being performed. That's a no-no. Again, the fix is simple. *** orig/fortune.c Mon Nov 9 15:19:28 1987 --- fortune.c Mon Nov 9 15:26:33 1987 *************** *** 312,318 * Make sure all values are in range. */ ! if (Tbl.str_delims[1] >= Tbl.str_delims[0]) Tbl.str_delims[1] %= Tbl.str_delims[0]; if (Tbl.str_delims[2] >= Tbl.str_numstr) { Tbl.str_delims[2] -= Tbl.str_delims[0]; --- 312,319 ----- * Make sure all values are in range. */ ! if ((Tbl.str_delims[1] >= Tbl.str_delims[0]) && ! ((Tbl.str_delims[1] != 0) && (Tbl.str_delims[0] != 0))) Tbl.str_delims[1] %= Tbl.str_delims[0]; if (Tbl.str_delims[2] >= Tbl.str_numstr) { Tbl.str_delims[2] -= Tbl.str_delims[0]; Enjoy - I do. -- Bill Wisner, HASA "A" Division ..{codas,ihnp4}!killer!billw "I don't mind at all.." -- Bourgeois Tagg