]> thyrsus.com Git - bs.git/commitdiff
gcc -Wall changes.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 7 May 1995 03:23:46 +0000 (03:23 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 7 May 1995 03:23:46 +0000 (03:23 +0000)
bs.c

diff --git a/bs.c b/bs.c
index 72528359ddac4dfb7dc9d8168af3da42491d036c..9448e6bf13c6303101b62c0bce9932ffb4e8e901 100644 (file)
--- 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 <stdio.h>
-#include <termios.h>
-#ifdef NCURSES
-#include <ncurses.h>
-#else
 #include <curses.h>
-#endif NCURSES
 #include <signal.h>
 #include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
 #include <assert.h>
 
+#ifndef SIGIOT
+#define SIGIOT SIGABRT
+#endif
+
 #ifndef A_UNDERLINE    /* BSD curses */
 #define        beep()  write(1,"\007",1);
 #define        cbreak  crmode
 #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;