Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!lll-winken!uunet!futures!scott From: scott@futures.UUCP (Scott Boyd) Newsgroups: comp.sources.games.bugs Subject: Scrabble diffs for non-ansi C compilers Keywords: scrabble diffs C Message-ID: <133@futures.UUCP> Date: 3 May 89 02:08:25 GMT Organization: Commodity Futures, Inc. Woodside, CA Lines: 1139 The scrabble game recently posted by Wayne Christopher requires an ANSI C or GNU C compiler to use. Attached are the diffs needed to build it on systems without an ANSI or GNU C compiler. These patches have been tested with both GNU C 1.34 (ANSI) compiler and the Sun C (non-ANSI) compiler on a Sun386i/250 using SunOS 4.01. Use Larry Wall's patch program to apply. Enjoy. ------------------------------------------------------------------------------- Scott Boyd Commodity Futures, Inc. uunet!futures!scott P.O. Box 620484 Woodside, CA 94062 ---------------------------- PATCHES START HERE ------------------------------- *** board.c.old Mon Apr 17 17:10:25 1989 --- board.c Mon Apr 17 16:56:52 1989 *************** *** 80,87 **** --- 80,94 ---- return (board); } + #ifdef _STDC_ void boardmove(board_t *board, move_t *move) + #else + void + boardmove(board, move) + board_t *board; + move_t *move; + #endif { int i; *************** *** 101,108 **** --- 108,121 ---- return; } + #ifdef _STDC_ char pickletter(board_t *board) + #else + char + pickletter(board) + board_t *board; + #endif { if (board->numleft) return (board->pool[--board->numleft]); *************** *** 115,122 **** --- 128,142 ---- static char lbchar[] = " `\"(<"; static char rbchar[] = " '\")>"; + #ifdef _STDC_ void printboard(board_t *board, FILE *fp) + #else + void + printboard(board,fp) + board_t *board; + FILE *fp; + #endif { int i, j; char c; *** dict.c.old Mon Apr 17 17:10:19 1989 --- dict.c Mon Apr 17 16:57:02 1989 *************** *** 10,23 **** --- 10,34 ---- #include "scrabble.h" + #ifdef _STDC_ static int dicthash(char *word, int tabsize); static void getem(word_t **wordp, char *lbuf, int place, char *opt, int numopt, int len); + #else + static int dicthash(); + static void getem(); + #endif static dict_t *dictionary; + #ifdef _STDC_ void readdict(char *file) + #else + void + readdict(file) + char *file; + #endif { FILE *fp; char buf[BSIZE], *e; *************** *** 88,95 **** --- 99,112 ---- return; } + #ifdef _STDC_ void writedict(char *file) + #else + void + writedict(file) + char *file; + #endif { int i, j, k = 0; word_t *word; *************** *** 117,124 **** --- 134,147 ---- return; } + #ifdef _STDC_ void addword(char *word) + #else + void + addword(word) + char *word; + #endif { int key = dicthash(word, HASH_SIZE); int len = strlen(word); *************** *** 144,151 **** --- 167,180 ---- return; } + #ifdef _STDC_ void remword(char *word) + #else + void + remword(word) + char *word; + #endif { int key = dicthash(word, HASH_SIZE); int len = strlen(word); *************** *** 169,176 **** --- 198,211 ---- return; } + #ifdef _STDC_ bool isaword(char *poss) + #else + bool + isaword(poss) + char *poss; + #endif { word_t *word; int len = strlen(poss); *************** *** 192,199 **** --- 227,244 ---- * up the length. */ + #ifdef _STDC_ word_t * getpossibles(char *opt, int numopt, char *req, int numreq, int len) + #else + word_t * + getpossibles(opt, numopt, req, numreq, len) + char *opt; + int numopt; + char *req; + int numreq; + int len; + #endif { char lbuf[SIZE]; int i; *************** *** 232,239 **** --- 277,295 ---- return (word); } + #ifdef _STDC_ static void getem(word_t **wordp, char *lbuf, int place, char *opt, int numopt, int len) + #else + static void + getem(wordp, lbuf, place, opt, numopt, len) + word_t **wordp; + char *lbuf; + int place; + char *opt; + int numopt; + int len; + #endif { int key; word_t *set, *ww; *************** *** 277,284 **** --- 333,347 ---- /* A return value of -1 denotes that this is a bad word. */ + #ifdef _STDC_ static int dicthash(char *word, int tabsize) + #else + static int + dicthash(word, tabsize) + char *word; + int tabsize; + #endif { int i; unsigned long result = 0; *** move.c.old Mon Apr 17 17:10:20 1989 --- move.c Mon Apr 17 16:57:17 1989 *************** *** 10,15 **** --- 10,16 ---- #include "scrabble.h" + #ifdef _STDC_ static void dopos(board_t *board, player_t *player, int x, int y, bool horiz, move_t *best); static int wordpoints(board_t *board, int x, int y, bool horiz, int len, *************** *** 18,26 **** --- 19,41 ---- static bool validword(board_t *board, int x, int y, int len, char subc, bool horiz, bool machine, bool check); static bool validlocation(board_t *board, int x, int y, bool horiz, int len); + #else + static void dopos(); + static int wordpoints(); + static bool validword(); + static bool validlocation(); + #endif + #ifdef _STDC_ void bestmove(board_t *board, player_t *player, move_t *best) + #else + void + bestmove(board, player, best) + board_t *board; + player_t *player; + move_t *best; + #endif { int x, y; move_t try; *************** *** 42,49 **** --- 57,72 ---- #ifdef notdef + #ifdef _STDC_ void printmove(int which, move_t *move, FILE *fp) + #else + void + printmove(which, move, fp) + int which; + move_t *move; + FILE *fp; + #endif { fprintf(fp, "Player %d: \"%s\", %s at (%d, %d) for %d points.\n", which, move->word, move->horiz ? "horiz" : "vert", *************** *** 54,61 **** --- 77,95 ---- #endif + #ifdef _STDC_ static void dopos(board_t *board, player_t *player, int x, int y, bool horiz, move_t *best) + #else + static void + dopos(board, player, x, y, horiz, best) + board_t *board; + player_t *player; + int x; + int y; + bool horiz; + move_t *best; + #endif { char opt[SIZE]; char req[SIZE]; *************** *** 132,139 **** --- 166,183 ---- return; } + #ifdef _STDC_ static bool validlocation(board_t *board, int x, int y, bool horiz, int len) + #else + static bool + validlocation(board, x, y, horiz, len) + board_t *board; + int x; + int y; + bool horiz; + int len; + #endif { int i; *************** *** 171,178 **** --- 215,231 ---- * be invalid. */ + #ifdef _STDC_ void trymove(move_t *move, board_t *board, player_t *player, bool check) + #else + void + trymove(move, board, player, check) + move_t *move; + board_t *board; + player_t *player; + bool check; + #endif { bool used[WORK_SIZE]; int numused = 0; *************** *** 319,327 **** --- 372,393 ---- return; } + #ifdef _STDC_ static bool validword(board_t *board, int x, int y, int len, char subc, bool horiz, bool machine, bool check) + #else + static bool + validword(board, x, y, len, subc, horiz, machine, check) + board_t *board; + int x; + int y; + int len; + char subc; + bool horiz; + bool machine; + bool check; + #endif { char buf[BSIZE], qbuf[BSIZE], c; int i; *************** *** 364,372 **** --- 430,450 ---- } } + #ifdef _STDC_ static int wordpoints(board_t *board, int x, int y, bool horiz, int len, char *word, char subc, int wx, int wy, bool allbonuses, bool *wilds) + #else + static int + wordpoints(board, x, y, horiz, len, word, subc, wx, wy, allbonuses, wilds) + board_t *board; + int x,y; + bool horiz; + int len; + char *word, subc; + int wx,wy; + bool allbonuses, *wilds; + #endif { int value = 0; int mult = 1; *** player.c.old Mon Apr 17 17:10:27 1989 --- player.c Mon Apr 17 16:57:24 1989 *************** *** 10,17 **** --- 10,24 ---- #include "scrabble.h" + #ifdef _STDC_ player_t * makeplayer(board_t *board, int num) + #else + player_t * + makeplayer(board, num) + board_t *board; + int num; + #endif { player_t *player = (player_t *) util_malloc(sizeof (player_t)); int i; *************** *** 51,58 **** --- 58,73 ---- /* Note that this must be called before boardmove. */ + #ifdef _STDC_ void playermove(board_t *board, player_t *player, move_t *move) + #else + void + playermove(board, player, move) + board_t *board; + player_t *player; + move_t *move; + #endif { int i, j, k; char c; *************** *** 121,128 **** --- 136,151 ---- #ifdef notdef + #ifdef _STDC_ void printplayer(player_t *player, int num, FILE *fp) + #else + void + printplayer(player, num, fp) + player_t *player; + int num; + FILE *fp; + #endif { int i; *** plural.c.old Mon Apr 17 17:10:27 1989 --- plural.c Mon Apr 17 16:57:39 1989 *************** *** 26,33 **** --- 26,39 ---- { "", "s" } } ; + #ifdef _STDC_ void pluralize(char *word) + #else + void + pluralize(word) + char *word; + #endif { int i, wl, sl; char *s, *t; *** savegame.c.old Mon Apr 17 17:10:28 1989 --- savegame.c Mon Apr 17 16:57:57 1989 *************** *** 10,35 **** --- 10,65 ---- #include "scrabble.h" + #ifdef _STDC_ board_t * restoregame(FILE *fp, int *nump, int *whosup, int *turn) + #else + board_t * + restoregame(fp, nump, whosup, turn) + FILE *fp; + int *nump; + int *whosup; + int *turn; + #endif { return (NULL); } + #ifdef _STDC_ player_t * restoreplayer(FILE *fp) + #else + player_t * + restoreplayer(fp) + FILE *fp; + #endif { return (NULL); } + #ifdef _STDC_ void savegame(FILE *fp, int nump, int whosup, int turn) + #else + void + savegame(fp, nump, whosup, turn) + FILE *fp; + int nump; + int whosup; + int turn; + #endif { return; } + #ifdef _STDC_ void saveplayer(FILE *fp) + #else + void + saveplayer(fp) + FILE *fp; + #endif { return; } *** scrabble.c.old Mon Apr 17 17:10:22 1989 --- scrabble.c Mon Apr 17 16:58:05 1989 *************** *** 16,28 **** --- 16,39 ---- bool userpick = false; bool confirm = false; + #ifdef _STDC_ static bool domove(board_t *board, player_t **players, int which); + #else + static bool domove(); + #endif static void sighandler(); static char *dictfile = DICT_FILE; + #ifdef _STDC_ int main(int ac, char **av) + #else + int + main(ac, av) + int ac; + char **av; + #endif { board_t *board; player_t *players[MAX_PLAYERS]; *************** *** 179,186 **** --- 190,205 ---- exit(1); } + #ifdef _STDC_ static bool domove(board_t *board, player_t **players, int which) + #else + static bool + domove(board, players, which) + board_t *board; + player_t **players; + int which; + #endif { move_t move; char buf[BSIZE]; *** tty.c.old Mon Apr 17 17:10:24 1989 --- tty.c Mon Apr 17 16:58:12 1989 *************** *** 50,57 **** --- 50,65 ---- " ? : Print this help message. " } ; + #ifdef _STDC_ void tty_init(board_t *board, player_t *players[], int numplayers) + #else + void + tty_init(board, players, numplayers) + board_t *board; + player_t *players[]; + int numplayers; + #endif { int i, j; int x, y; *************** *** 121,128 **** --- 129,142 ---- return; } + #ifdef _STDC_ void tty_message(char *message) + #else + void + tty_message(message) + char *message; + #endif { /* Print the message and clear the line below it. */ messline = (messline + 1) % MESS_SIZE; *************** *** 139,146 **** --- 153,166 ---- return; } + #ifdef _STDC_ char * tty_question(char *message) + #else + char * + tty_question(message) + char *message; + #endif { static char buf[BSIZE]; *************** *** 156,163 **** --- 176,189 ---- return (buf); } + #ifdef _STDC_ bool tty_confirm(char *message) + #else + bool + tty_confirm(message) + char *message; + #endif { char c; *************** *** 176,183 **** --- 202,217 ---- * a word. Other commands are 'T', 'S', 'R', 'Q', and '?'. */ + #ifdef _STDC_ command_t tty_command(board_t *board, player_t *player, move_t *mv) + #else + command_t + tty_command(board, player, mv) + board_t *board; + player_t *player; + move_t *mv; + #endif { int x = 7, y = 7; int px, py; *************** *** 300,307 **** --- 334,349 ---- return (MOVE); } + #ifdef _STDC_ void tty_drawplayer(player_t *player, int pos, bool up) + #else + void + tty_drawplayer(player, pos, up) + player_t *player; + int pos; + bool up; + #endif { int i; *************** *** 317,324 **** --- 359,373 ---- return; } + #ifdef _STDC_ void tty_drawsummary(board_t *board, int turn) + #else + void + tty_drawsummary(board, turn) + board_t *board; + int turn; + #endif { wmove(summary, 0, 0); wprintw(summary, " Game turn: %d ", turn); *************** *** 329,336 **** --- 378,393 ---- return; } + #ifdef _STDC_ void tty_drawmove(board_t *board, move_t *mv, player_t *player) + #else + void + tty_drawmove(board, mv, player) + board_t *board; + move_t *mv; + player_t *player; + #endif { int i, x, y; char c; *** user.c.old Mon Apr 17 17:10:29 1989 --- user.c Mon Apr 17 16:58:20 1989 *************** *** 13,18 **** --- 13,19 ---- #include "scrabble.h" struct device { + #ifdef _STDC_ void (*init)(board_t *board, player_t *players[], int numplayers); void (*message)(char *message); char *(*question)(char *message); *************** *** 21,26 **** --- 22,37 ---- void (*drawplayer)(player_t *player, int pos, bool up); void (*drawsummary)(board_t *board, int turn); void (*drawmove)(board_t *board, move_t *move, player_t *player); + #else + void (*init)(); + void (*message)(); + char *(*question)(); + bool (*confirm)(); + command_t (*command)(); + void (*drawplayer)(); + void (*drawsummary)(); + void (*drawmove)(); + #endif void (*givehelp)(); void (*update)(); void (*cleanup)(); *************** *** 42,49 **** --- 53,69 ---- static struct device *dev; + #ifdef _STDC_ void user_init(devtype_t type, board_t *board, player_t *players[], int numplayers) + #else + void + user_init(type, board, players, numplayers) + devtype_t type; + board_t *board; + player_t *players[]; + int numplayers; + #endif { switch (type) { case DEV_TTY: dev = &tty_device; break; *************** *** 54,100 **** --- 74,169 ---- return; } + #ifdef _STDC_ void user_message(char *message) + #else + void + user_message(message) + char *message; + #endif { (dev->message)(message); return; } + #ifdef _STDC_ char * user_question(char *message) + #else + char * + user_question(message) + char *message; + #endif { return ((dev->question)(message)); } + #ifdef _STDC_ bool user_confirm(char *message) + #else + bool + user_confirm(message) + char *message; + #endif { return ((dev->confirm)(message)); } + #ifdef _STDC_ command_t user_command(board_t *board, player_t *player, move_t *move) + #else + command_t + user_command(board, player, move) + board_t *board; + player_t *player; + move_t *move; + #endif { return ((dev->command)(board, player, move)); } + #ifdef _STDC_ void user_drawplayer(player_t *player, int pos, bool up) + #else + void + user_drawplayer(player, pos, up) + player_t *player; + int pos; + bool up; + #endif { (dev->drawplayer)(player, pos, up); return; } + #ifdef _STDC_ void user_drawsummary(board_t *board, int turn) + #else + void + user_drawsummary(board, turn) + board_t *board; + int turn; + #endif { (dev->drawsummary)(board, turn); return; } + #ifdef _STDC_ void user_drawmove(board_t *board, move_t *move, player_t *player) + #else + void + user_drawmove(board, move, player) + board_t *board; + move_t *move; + player_t *player; + #endif { (dev->drawmove)(board, move, player); return; *************** *** 123,130 **** --- 192,207 ---- #ifdef notdef + #ifdef _STDC_ bool readmove(board_t *board, player_t *player, move_t *move) + #else + bool + readmove(board, player, move) + board_t *board; + player_t *player; + move_t *move; + #endif { char buf[BSIZE]; int x, y, i; *** date.h.old Mon Apr 17 17:10:18 1989 --- date.h Mon Apr 10 13:19:03 1989 *************** *** 1,3 **** ! #define DATE "Thu Apr 6 12:36:51 PDT 1989" ! #define HOST "saab" ! #define USER "billr" --- 1,3 ---- ! #define DATE "Mon Apr 10 13:18:44 PDT 1989" ! #define HOST "futures" ! #define USER "scott" *** scrabble.h.old Mon Apr 17 17:10:23 1989 --- scrabble.h Mon Apr 17 16:59:02 1989 *************** *** 120,126 **** --- 120,130 ---- /* scrabble.c */ + #ifdef _STDC_ extern int main(int ac, char **av); + #else + extern int main(); + #endif extern dict_t *dictionaries; extern bool debug; extern bool userpick; *************** *** 128,135 **** --- 132,144 ---- /* board.c */ extern board_t *makeboard(); + #ifdef _STDC_ extern void boardmove(board_t *board, move_t *move); extern char pickletter(board_t *board); + #else + extern void boardmove(); + extern char pickletter(); + #endif extern int letterpoint_values[]; /* extern void printboard(board_t *board, FILE *fp); */ *************** *** 136,148 **** --- 145,163 ---- /* move.c */ + #ifdef _STDC_ extern void bestmove(board_t *board, player_t *player, move_t *best); extern void trymove(move_t *move, board_t *board, player_t *player, bool check); + #else + extern void bestmove(); + extern void trymove(); + #endif /* extern void printmove(int which, move_t *move, FILE *fp); */ /* dict.c */ + #ifdef _STDC_ extern void readdict(char *file); extern word_t *getpossibles(char *req, int numreq, char *opt, int numopt, int len); *************** *** 150,172 **** --- 165,208 ---- extern void addword(char *word); extern void remword(char *word); extern void writedict(char *file); + #else + extern void readdict(); + extern word_t *getpossibles(); + extern bool isaword(); + extern void addword(); + extern void remword(); + extern void writedict(); + #endif /* player.c */ + #ifdef _STDC_ extern player_t *makeplayer(board_t *board, int num); extern void playermove(board_t *board, player_t *player, move_t *move); + #else + extern player_t *makeplayer(); + extern void playermove(); + #endif /* extern void printplayer(player_t *player, int num, FILE *fp); */ /* savegame.c */ + #ifdef _STDC_ extern board_t *restoregame(FILE *fp, int *nump, int *whosup, int *turn); extern player_t *restoreplayer(FILE *fp); extern void savegame(FILE *fp, int nump, int whosup, int turn); extern void saveplayer(FILE *fp); + #else + extern board_t *restoregame(); + extern player_t *restoreplayer(); + extern void savegame(); + extern void saveplayer(); + #endif /* user.c */ + #ifdef _STDC_ extern void user_init(devtype_t type, board_t *board, player_t *players[], int numplayers); extern void user_message(char *message); *************** *** 176,181 **** --- 212,227 ---- extern void user_drawplayer(player_t *player, int pos, bool up); extern void user_drawsummary(board_t *board, int turn); extern void user_drawmove(board_t *board, move_t *move, player_t *player); + #else + extern void user_init(); + extern void user_message(); + extern char *user_question(); + extern bool user_confirm(); + extern command_t user_command(); + extern void user_drawplayer(); + extern void user_drawsummary(); + extern void user_drawmove(); + #endif extern void user_givehelp(); extern void user_update(); extern void user_cleanup(); *************** *** 184,189 **** --- 230,236 ---- /* tty.c */ + #ifdef _STDC_ extern void tty_init(board_t *board, player_t *players[], int numplayers); extern void tty_message(char *message); extern char *tty_question(char *message); *************** *** 192,197 **** --- 239,254 ---- extern void tty_drawplayer(player_t *player, int pos, bool up); extern void tty_drawsummary(board_t *board, int turn); extern void tty_drawmove(board_t *board, move_t *mv, player_t *player); + #else + extern void tty_init(); + extern void tty_message(); + extern char *tty_question(); + extern bool tty_confirm(); + extern command_t tty_command(); + extern void tty_drawplayer(); + extern void tty_drawsummary(); + extern void tty_drawmove(); + #endif extern void tty_givehelp(); extern void tty_update(); extern void tty_cleanup(); *** Makefile.old Mon Apr 17 17:10:17 1989 --- Makefile Mon Apr 10 12:27:59 1989 *************** *** 15,21 **** #---- Tool specific stuff ---- ! DICT_DEF = -DDICT_FILE=\"dictionary\" PROGRAM = scrabble --- 15,21 ---- #---- Tool specific stuff ---- ! DICT_DEF = -DDICT_FILE=\"/usr/dict/words\" PROGRAM = scrabble *************** *** 69,75 **** MISC = ! CC = gcc -W -fwritable-strings OPT_LIBS = $(SPEC_OPT_LIBS) --- 69,75 ---- MISC = ! #CC = gcc -W -fwritable-strings OPT_LIBS = $(SPEC_OPT_LIBS) *************** *** 77,83 **** PROF_LIBS = $(SPEC_PROF_LIBS) ! OPT_LDFLAGS = -lcurses -ltermlib -lX -lm -O DEBUG_LDFLAGS = -lcurses -ltermlib -lX -lm -g --- 77,84 ---- PROF_LIBS = $(SPEC_PROF_LIBS) ! #OPT_LDFLAGS = -lcurses -ltermlib -lX -lm -O ! OPT_LDFLAGS = -lcurses -ltermlib -lm -O DEBUG_LDFLAGS = -lcurses -ltermlib -lX -lm -g *************** *** 87,93 **** #---- State ---- ! CFLAGS=-O -g LIBS=$(OPT_LIBS) LDFLAGS=$(OPT_LDFLAGS) --- 88,95 ---- #---- State ---- ! #CFLAGS=-O -g ! CFLAGS=-g LIBS=$(OPT_LIBS) LDFLAGS=$(OPT_LDFLAGS) -- ------------------------------------------------------------------------------- Scott Boyd Commodity Futures, Inc. uunet!futures!scott P.O. Box 620484 Woodside, CA 94062