From: Eric S. Raymond Date: Tue, 25 Jul 2006 17:21:51 +0000 (+0000) Subject: ANSIfy the code by making void prototype declarations explicit. X-Git-Tag: 1.8~10 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=effc04d2584ed1a3f1e24e29ac41e993edb0c536;p=vms-empire.git ANSIfy the code by making void prototype declarations explicit. --- diff --git a/display.c b/display.c index 81ac92b..2ae3e7d 100644 --- a/display.c +++ b/display.c @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.11 2006/07/25 16:51:22 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: display.c,v 1.12 2006/07/25 16:58:26 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -35,7 +35,7 @@ static void disp_square(view_map_t *vp); int on_screen(long loc); #ifdef A_COLOR -void init_colors() +void init_colors(void) { start_color(); @@ -62,7 +62,7 @@ This routine is called when the current display has been trashed and no sector is shown on the screen. */ -void kill_display () { +void kill_display (void) { whose_map = UNOWNED; } @@ -71,7 +71,7 @@ This routine is called when a new sector may be displayed on the screen even if the location to be displayed is already on the screen. */ -void sector_change () { +void sector_change (void) { change_ok = TRUE; } @@ -80,7 +80,7 @@ Return the currently displayed user sector, if any. If a user sector is not displayed, return -1. */ -int cur_sector () { +int cur_sector (void) { if (whose_map != USER) return (-1); return (save_sector); } @@ -90,7 +90,7 @@ Return the current position of the cursor. If the user's map is not on the screen, we return -1. */ -long cur_cursor () { +long cur_cursor (void) { if (whose_map != USER) return (-1); return (save_cursor); } @@ -110,8 +110,6 @@ int whose; /* whose map to display */ view_map_t vmap[]; long loc; /* location to display */ { - void print_sector(); - if (change_ok || whose != whose_map || !on_screen (loc)) print_sector (whose, vmap, loc_sector (loc)); @@ -383,7 +381,7 @@ void print_zoom (vmap) view_map_t *vmap; { - void print_zoom_cell(); + void print_zoom_cell (); int row_inc, col_inc; int r, c; @@ -510,7 +508,7 @@ Display the score off in the corner of the screen. */ void -display_score () +display_score (void) { pos_str (1, cols-12, " User Comp",0,0,0,0,0,0,0,0); pos_str (2, cols-12, "%5d %5d", user_score, comp_score,0,0,0,0,0,0); @@ -533,7 +531,7 @@ Initialize the terminal. */ void -ttinit() +ttinit(void) { (void) initscr(); (void) noecho(); @@ -556,7 +554,7 @@ display. */ void -clear_screen () { +clear_screen (void) { (void) clear (); (void) refresh (); kill_display (); @@ -567,12 +565,12 @@ Redraw the screen. */ void -redisplay () { +redisplay (void) { (void) refresh (); } void -redraw () { +redraw (void) { (void) clearok (curscr, TRUE); (void) refresh (); } @@ -583,7 +581,7 @@ the screen and pause for a few milliseconds. */ void -delay () { +delay (void) { int t = delay_time; int i = 500; (void) refresh (); @@ -604,7 +602,7 @@ Clean up the display. This routine gets called as we leave the game. */ void -close_disp() +close_disp(void) { (void) move (LINES - 1, 0); (void) clrtoeol (); diff --git a/edit.c b/edit.c index 67dbf10..564cc8f 100644 --- a/edit.c +++ b/edit.c @@ -19,7 +19,7 @@ edit.c -- Routines to handle edit mode commands. #include "extern.h" void e_move(long *path_start, long loc); -extern int get_piece_name(); +extern int get_piece_name(void); void edit(edit_cursor) @@ -149,7 +149,7 @@ Leave edit mode. */ void -e_leave () { +e_leave (void) { } /* @@ -634,7 +634,7 @@ get help */ void -e_help () { +e_help (void) { help (help_edit, edit_lines); prompt ("Press any key to continue: ",0,0,0,0,0,0,0,0); (void) get_chx (); diff --git a/empire.c b/empire.c index db5e75a..17fc695 100644 --- a/empire.c +++ b/empire.c @@ -1,4 +1,4 @@ -/* $Id: empire.c,v 1.5 2006/07/25 15:59:54 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: empire.c,v 1.6 2006/07/25 16:43:14 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -16,7 +16,7 @@ parser, and the simple commands. #include "empire.h" #include "extern.h" -void c_examine(), c_movie(); +void c_examine(void), c_movie(void); /* * 03a 01Apr88 aml .Hacked movement algorithms for computer. @@ -27,7 +27,7 @@ void c_examine(), c_movie(); */ void -empire () { +empire (void) { void do_command(); void print_zoom(); @@ -72,8 +72,8 @@ void do_command (orders) char orders; { - void c_debug(), c_quit(), c_sector(), c_map(); - void c_give(); + void c_debug(), c_quit(void), c_sector(void), c_map(void); + void c_give(void); char e; int ncycle; @@ -255,7 +255,7 @@ The quit command. Make sure the user really wants to quit. */ void -c_quit () { +c_quit (void) { if (getyn ("QUIT - Are you sure? ")) { empend (); } @@ -267,7 +267,7 @@ and print it. */ void -c_sector () { +c_sector (void) { int num; num = get_range ("Sector number? ", 0, NUM_SECTORS-1); @@ -282,7 +282,7 @@ out the map. */ void -c_map () { +c_map (void) { FILE *f; int i, j; char line[MAP_HEIGHT+2]; @@ -315,7 +315,7 @@ Allow user to examine the computer's map. */ void -c_examine () { +c_examine (void) { int num; num = get_range ("Sector number? ", 0, NUM_SECTORS-1); @@ -328,7 +328,7 @@ Print a "zoomed" version of the computer's map. */ void -c_movie () { +c_movie (void) { (void) clear (); for (;;) { comp_move (1); diff --git a/extern.h b/extern.h index 9b7c8b6..a9f8957 100644 --- a/extern.h +++ b/extern.h @@ -1,4 +1,4 @@ -/* $Id: extern.h,v 1.9 2006/07/25 16:43:14 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: extern.h,v 1.10 2006/07/25 16:58:26 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -108,11 +108,11 @@ char *savefile; /* global routines */ -void empire(); +void empire(void); void attack(piece_info_t *att_obj, long loc); void comp_move(int nmoves); -void user_move(); +void user_move(void); void edit(long edit_cursor); /* map routines */ @@ -141,11 +141,11 @@ int rmap_at_sea (long loc); /* display routines */ void announce (char *); -void redisplay(); -void kill_display (); -void sector_change (); -int cur_sector (); -long cur_cursor (); +void redisplay (void); +void kill_display (void); +void sector_change (void); +int cur_sector (void); +long cur_cursor (void); void display_loc (int whose, view_map_t vmap[], long loc); void display_locx (int whose, view_map_t vmap[], long loc); void print_sector (int whose, view_map_t vmap[], int sector); @@ -153,36 +153,36 @@ int move_cursor (long *cursor, int offset); void print_zoom (view_map_t *vmap); void print_pzoom (char *s, path_map_t *pmap, view_map_t *vmap); void print_xzoom (view_map_t *vmap); -void display_score (); +void display_score (void); #ifdef A_COLOR -void init_colors (); +void init_colors (void); #endif /* A_COLOR */ -void redraw (); -void clear_screen (); -void delay (); -void close_disp (); +void redraw (void); +void clear_screen (void); +void delay (void); +void close_disp (void); void pos_str (int row, int col, char *str, int a, int b, int c, int d, int e, int f, int g, int h); void pos_str1 (int row, int col, char *str, char *a, int b, int c, int d, int e, int f, int g, int h); void addprintf (char *str, int a, int b, int c, int d, int e, int f, int g, int h); void addprintf1 (char *str, char *a, int b, int c, int d, int e, int f, int g, int h); void addprintf2 (char *str, char *a, int b, int c, int d, char *e, char *f, int g, int h); -void init_game (); /* game routines */ -void save_game (); -int restore_game (); -void save_movie_screen (); -void replay_movie (); +void init_game (void); /* game routines */ +void save_game (void); +int restore_game (void); +void save_movie_screen (void); +void replay_movie (void); void get_str (char *buf, int sizep); /* input routines */ void get_strq (char *buf, int sizep); -char get_chx (); +char get_chx (void); int getint (char *message); -char get_c (); -char get_cq (); +char get_c (void); +char get_cq (void); int getyn (char *message); int get_range (char *message, int low, int high); -void rndini (); /* math routines */ +void rndini (void); /* math routines */ long irand (long high); int dist (long a, long b); int isqrt (int n); @@ -210,7 +210,7 @@ void set_prod (city_info_t *cityp); /* terminal routines */ void pdebug (char *s, int a, int b, int c, int d, int e, int f, int g, int h); -void topini (); +void topini (void); void clreol (int linep, int colp); void topmsg (int linep, char *buf, int a, int b, int c, int d, int e, int f, int g, int h); void topmsg1 (int linep, char *buf, char *a, int b, int c, int d, int e, int f, int g, int h); @@ -223,26 +223,17 @@ void info (char *a, char *b, char *c); void comment (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); void comment1 (char *buf,char *a, int b, int c, int d, int e, int f, int g, int h); void extra (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); -void huh (); +void huh (void); void help (char **text, int nlines); -void set_need_delay (); +void set_need_delay (void); void ksend (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); void ksend1 (char *buf, char *a, int b, int c, int d, int e, int f, int g, int h); /* utility routines */ -void ttinit (); +void ttinit (void); void assert (char *expression, char *file, int line); -void empend (); +void empend (void); char upper (char c); void tupper (char *str); -void check (); +void check (void); int loc_disp (int loc); - -/* randon routines we use */ -long time(); -void exit(); -void perror(); -void srand(); -#ifndef LINUX -char *strcpy(); -#endif diff --git a/game.c b/game.c index f59d4c5..7171a77 100644 --- a/game.c +++ b/game.c @@ -12,13 +12,14 @@ game.c -- Routines to initialize, save, and restore a game. */ #include +#include #include #include #include "empire.h" #include "extern.h" long remove_land(long loc, long num_land); -int select_cities(); +int select_cities(void); int find_next(long *mapi); int good_cont(long mapi); int xread(FILE *f, char *buf, int size); @@ -31,8 +32,8 @@ on the map, select cities for each opponent, and zero out the lists of pieces on the board. */ -void init_game () { - void make_map(), place_cities(); +void init_game (void) { + void make_map(void), place_cities(void); long i; @@ -96,7 +97,7 @@ at program start up. static int height[2][MAP_SIZE]; static int height_count[MAX_HEIGHT+1]; -void make_map () { +void make_map (void) { int from, to, k; long i, j, sum, loc; @@ -167,7 +168,7 @@ for a city, we remove land cells which are too close to the city. /* avoid compiler problems with large automatic arrays */ static long land[MAP_SIZE]; -void place_cities () { +void place_cities (void) { long regen_land(); long placed, i, loc; @@ -295,8 +296,8 @@ static cont_t cont_tab[MAX_CONT]; /* list of good continenets */ static int rank_tab[MAX_CONT]; /* indices to cont_tab in order of rank */ static pair_t pair_tab[MAX_CONT*MAX_CONT]; /* ranked pairs of continents */ -int select_cities () { - void find_cont(), make_pair(); +int select_cities (void) { + void find_cont(void), make_pair(void); long compi, useri; city_info_t *compp, *userp; @@ -345,7 +346,7 @@ Find all continents with 2 cities or more, one of which must be a shore city. We rank the continents. */ -void find_cont () { +void find_cont (void) { long i; long mapi; @@ -398,7 +399,7 @@ continent and return true. Otherwise we return false. */ static long ncity, nland, nshore; -static void mark_cont(); +static void mark_cont(long); int good_cont (mapi) long mapi; @@ -464,7 +465,7 @@ win with. Our ranking is simply based on the difference in value between the user's continent and the computer's continent. */ -void make_pair () { +void make_pair (void) { int i, j, k, npair; long val; @@ -499,7 +500,7 @@ tell the user why. #define wbuf(buf) if (!xwrite (f, (char *)buf, sizeof (buf))) return #define wval(val) if (!xwrite (f, (char *)&val, sizeof (val))) return -void save_game () { +void save_game (void) { FILE *f; /* file to save game in */ f = fopen (savefile, "w"); /* open for output */ @@ -536,7 +537,7 @@ We return TRUE if we succeed, otherwise FALSE. #define rbuf(buf) if (!xread (f, (char *)buf, sizeof(buf))) return (FALSE); #define rval(val) if (!xread (f, (char *)&val, sizeof(val))) return (FALSE); -int restore_game () { +int restore_game (void) { void read_embark(); FILE *f; /* file to save game in */ @@ -627,7 +628,7 @@ void read_embark (list, piece_type) piece_info_t *list; int piece_type; { - void inconsistent(); + void inconsistent(void); piece_info_t *ship; piece_info_t *obj; @@ -648,7 +649,7 @@ int piece_type; } } -void inconsistent () { +void inconsistent (void) { (void) printf ("saved game is inconsistent. Please remove it.\n"); exit (1); } @@ -711,7 +712,7 @@ extern char city_char[]; static char mapbuf[MAP_SIZE]; void -save_movie_screen () +save_movie_screen (void) { FILE *f; /* file to save game in */ long i; @@ -744,7 +745,7 @@ print it using a zoomed display. */ void -replay_movie () +replay_movie (void) { void print_movie_cell(); diff --git a/object.c b/object.c index f7d798b..71ad82a 100644 --- a/object.c +++ b/object.c @@ -17,7 +17,7 @@ object.c -- routines for manipulating objects. #include "empire.h" #include "extern.h" -extern int get_piece_name(); +extern int get_piece_name(void); /* Find the nearest city to a location. Return the location @@ -544,7 +544,7 @@ scan (vmap, loc) view_map_t vmap[]; long loc; { - void update(), check(); + void update(), check(void); int i; long xloc; @@ -652,7 +652,7 @@ city_info_t *cityp; /* Get the name of a type of object. */ int -get_piece_name () +get_piece_name (void) { char c; int i; diff --git a/usermove.c b/usermove.c index 20ab45c..4eefaa6 100644 --- a/usermove.c +++ b/usermove.c @@ -21,10 +21,10 @@ void fatal(piece_info_t *obj,long loc,char *message,char *response); void move_to_dest(piece_info_t *obj,long dest); void move_army_to_city(piece_info_t *obj,long city_loc); int awake(piece_info_t *obj); -extern int get_piece_name(); +extern int get_piece_name(void); void -user_move () { +user_move (void) { void piece_move(); int i, j, sec, sec_start; @@ -628,7 +628,7 @@ Print out help information. */ void -user_help () { +user_help (void) { char c; help (help_user, user_lines); @@ -1040,7 +1040,7 @@ Cancel automove mode. */ void -user_cancel_auto () { +user_cancel_auto (void) { if (!automove) comment ("Not in auto mode!",0,0,0,0,0,0,0,0); else { @@ -1054,7 +1054,7 @@ Redraw the screen. */ void -user_redraw () { +user_redraw (void) { redraw (); } diff --git a/util.c b/util.c index e53670b..e67b9f7 100644 --- a/util.c +++ b/util.c @@ -1,4 +1,4 @@ -/* $Id: util.c,v 1.5 2006/07/25 15:59:54 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: util.c,v 1.6 2006/07/25 16:43:14 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -12,6 +12,7 @@ util.c -- various utility routines. */ #include +#include #include #include #include "empire.h"