From 2a218256d27aceeb9367a498f8afab63bfdecfd4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 7 May 1995 03:23:46 +0000 Subject: [PATCH] gcc -Wall changes. --- bs.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/bs.c b/bs.c index 7252835..9448e6b 100644 --- a/bs.c +++ b/bs.c @@ -6,20 +6,22 @@ * v1.2 with color support and minor portability fixes, November 1990 * v2.0 featuring strict ANSI/POSIX conformance, November 1993. * v2.1 for Linux, October 1994. + * Slipstreamed in fixes to make it gcc -Wall clean, May '95. */ #define _POSIX_SOURCE -#include -#include -#ifdef NCURSES -#include -#else #include -#endif NCURSES #include #include +#include +#include +#include #include +#ifndef SIGIOT +#define SIGIOT SIGABRT +#endif + #ifndef A_UNDERLINE /* BSD curses */ #define beep() write(1,"\007",1); #define cbreak crmode @@ -30,10 +32,14 @@ #endif /* !A_UNDERLINE */ #ifdef isxdigit /* aha, must be an AT&T system... */ + +#if !defined(__386BSD__) && !defined(__bsdi__) #define srand(n) srand48(n) #define rand() lrand48() extern long lrand48(); extern void srand48(); +#endif + #define bzero(s, n) (void)memset((char *)(s), '\0', n) extern char *memset(); /* @@ -137,7 +143,7 @@ typedef struct char symbol; /* symbol for game purposes */ char length; /* length of ship */ char x, y; /* coordinates of ship start point */ - char dir; /* direction of `bow' */ + unsigned char dir; /* direction of `bow' */ bool placed; /* has it been placed on the board? */ } ship_t; @@ -219,7 +225,7 @@ static void intro() if(signal(SIGQUIT,SIG_IGN) != SIG_IGN) (void)signal(SIGQUIT,uninitgame); - if(tmpname = getlogin()) + if((tmpname = getlogin()) != 0) { (void)strcpy(name,tmpname); name[0] = toupper(name[0]); @@ -633,7 +639,7 @@ int y, x; int collide; /* anything on the square */ - if (collide = IS_SHIP(board[b][x][y])) + if ((collide = IS_SHIP(board[b][x][y])) != 0) return(collide); /* anything on the neighbors */ @@ -799,7 +805,7 @@ static int plyturn() { ship_t *ss; bool hit; - char *m; + char *m = NULL; prompt(1, "Where do you want to shoot? "); for (;;) @@ -947,12 +953,12 @@ static bool cpufire(x, y) int x, y; { bool hit, sunk; - ship_t *ss; + ship_t *ss = NULL; hits[COMPUTER][x][y] = (hit = (board[PLAYER][x][y])) ? MARK_HIT : MARK_MISS; (void) mvprintw(PROMPTLINE, 0, "I shoot at %c%d. I %s!", y + 'A', x, hit ? "hit" : "miss"); - if (sunk = (hit && (ss = hitship(x, y)))) + if ((sunk = (hit && (ss = hitship(x, y))))) (void) printw(" I've sunk your %s", ss->name); (void)clrtoeol(); @@ -1101,7 +1107,7 @@ static bool cputurn() return(hit); } -playagain() +int playagain() { int j; ship_t *ss; -- 2.43.0