billw@killer.UUCP (11/10/87)
[ 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, <sys/types.h> is scanned twice and all the typedefs repeated. Our compiler didn't like that. Quickie fix is to remove the #include <sys/types.h> 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 <sys/types.h> - # 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