switch source tree from k&r to c99

This commit is contained in:
nhmall
2021-01-26 21:06:16 -05:00
parent a2a9cb7b4f
commit f963c5aca7
232 changed files with 12099 additions and 17782 deletions

View File

@@ -23,7 +23,7 @@ extern char erase_char, kill_char;
/*
* Note:
*
* FIXME
* Prototypes need to use the widened/unwidened type macros (CHAR_P, &c)
* in order to match fields of the window_procs struct (see winprocs.h).
* But for a standard-conforming compiler, we'll end up with the widened
@@ -60,11 +60,11 @@ typedef struct nhmi {
winid wid; /* NetHack window id */
glyph_info glyphinfo; /* holds menu glyph and additional glyph info */
anything identifier; /* Value returned if item selected */
CHAR_P accelerator; /* Character used to select item from menu */
CHAR_P group_accel; /* Group accelerator for menu item, if any */
char accelerator; /* Character used to select item from menu */
char group_accel; /* Group accelerator for menu item, if any */
int attr; /* Text attributes for item */
const char *str; /* Text of menu item */
BOOLEAN_P presel; /* Whether menu item should be preselected */
boolean presel; /* Whether menu item should be preselected */
boolean selected; /* Whether item is currently selected */
unsigned itemflags;
int page_num; /* Display page number for entry */
@@ -225,7 +225,7 @@ curses_line_input_dialog(const char *prompt, char *answer, int buffer)
int
curses_character_input_dialog(const char *prompt, const char *choices,
CHAR_P def)
char def)
{
WINDOW *askwin = NULL;
#ifdef PDCURSES
@@ -390,7 +390,7 @@ curses_character_input_dialog(const char *prompt, const char *choices,
/* Return an extended command from the user */
int
curses_ext_cmd()
curses_ext_cmd(void)
{
int count, letter, prompt_width, startx, starty, winx, winy;
int messageh, messagew, maxlen = BUFSZ - 1;
@@ -624,8 +624,8 @@ curs_new_menu_item(winid wid, const char *str)
void
curses_add_nhmenu_item(winid wid, const glyph_info *glyphinfo,
const ANY_P *identifier, CHAR_P accelerator,
CHAR_P group_accel, int attr,
const ANY_P *identifier, char accelerator,
char group_accel, int attr,
const char *str, unsigned itemflags)
{
nhmenu_item *new_item, *current_items, *menu_item_ptr;

View File

@@ -10,12 +10,12 @@
void curses_line_input_dialog(const char *prompt, char *answer, int buffer);
int curses_character_input_dialog(const char *prompt, const char *choices,
CHAR_P def);
char def);
int curses_ext_cmd(void);
void curses_create_nhmenu(winid wid, unsigned long);
void curses_add_nhmenu_item(winid wid, const glyph_info *glyphinfo,
const ANY_P *identifier, CHAR_P accelerator,
CHAR_P group_accel, int attr,
const ANY_P *identifier, char accelerator,
char group_accel, int attr,
const char *str, unsigned itemflags);
void curs_menu_set_bottom_heavy(winid);
void curses_finalize_nhmenu(winid wid, const char *prompt);

View File

@@ -108,7 +108,7 @@ set_window_position(int *winx, int *winy, int *winw, int *winh,
/* Create the "main" nonvolatile windows used by nethack */
void
curses_create_main_windows()
curses_create_main_windows(void)
{
int min_message_height = 1;
int message_orientation = 0;
@@ -298,7 +298,7 @@ curses_create_main_windows()
/* Initialize curses colors to colors used by NetHack */
void
curses_init_nhcolors()
curses_init_nhcolors(void)
{
#ifdef TEXTCOLOR
if (has_colors()) {
@@ -411,7 +411,7 @@ curses_init_nhcolors()
/* Allow player to pick character's role, race, gender, and alignment.
Borrowed from the Gnome window port. */
void
curses_choose_character()
curses_choose_character(void)
{
int n, i, sel, count_off, pick4u;
int count = 0;
@@ -775,7 +775,7 @@ curses_character_dialog(const char **choices, const char *prompt)
/* Initialize and display options appropriately */
void
curses_init_options()
curses_init_options(void)
{
/* change these from set_gameview to set_in_game */
set_wc_option_mod_status(WC_ALIGN_MESSAGE | WC_ALIGN_STATUS, set_in_game);
@@ -846,7 +846,7 @@ curses_init_options()
/* Display an ASCII splash screen if the splash_screen option is set */
void
curses_display_splash_window()
curses_display_splash_window(void)
{
int i, x_start, y_start;
@@ -880,7 +880,7 @@ curses_display_splash_window()
/* Restore colors and cursor state before exiting */
void
curses_cleanup()
curses_cleanup(void)
{
#ifdef TEXTCOLOR
if (has_colors() && can_change_color()) {

View File

@@ -55,7 +55,7 @@ curses_update_inv(void)
/* Adds an inventory item. 'y' is 1 rather than 0 for the first item. */
void
curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, CHAR_P accelerator,
curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, char accelerator,
attr_t attr, const char *str)
{
WINDOW *win = curses_get_nhwin(INV_WIN);

View File

@@ -230,7 +230,7 @@ curses_init_nhwindows(int *argcp UNUSED,
the process. You need to fill in pl_character[0].
*/
void
curses_player_selection()
curses_player_selection(void)
{
curses_choose_character();
}
@@ -238,7 +238,7 @@ curses_player_selection()
/* Ask the user for a player name. */
void
curses_askname()
curses_askname(void)
{
#ifdef SELECTSAVED
if (iflags.wc2_selectsaved && !iflags.renameinprogress)
@@ -271,7 +271,7 @@ curses_askname()
A noop for the tty and X window-ports.
*/
void
curses_get_nh_event()
curses_get_nh_event(void)
{
boolean do_reset = FALSE;
@@ -330,7 +330,7 @@ curses_suspend_nhwindows(const char *str UNUSED)
/* Restore the windows after being suspended. */
void
curses_resume_nhwindows()
curses_resume_nhwindows(void)
{
curses_refresh_nethack_windows();
}
@@ -380,7 +380,7 @@ curses_clear_nhwindow(winid wid)
--more--, if necessary, in the tty window-port.
*/
void
curses_display_nhwindow(winid wid, BOOLEAN_P block)
curses_display_nhwindow(winid wid, boolean block)
{
menu_item *selected = NULL;
@@ -489,7 +489,7 @@ curses_putstr(winid wid, int attr, const char *text)
iff complain is TRUE.
*/
void
curses_display_file(const char *filename, BOOLEAN_P must_exist)
curses_display_file(const char *filename, boolean must_exist)
{
curses_view_file(filename, must_exist);
}
@@ -544,7 +544,7 @@ add_menu(winid wid, const glyph_info *glyphinfo,
void
curses_add_menu(winid wid, const glyph_info *glyphinfo,
const ANY_P * identifier,
CHAR_P accelerator, CHAR_P group_accel, int attr,
char accelerator, char group_accel, int attr,
const char *str, unsigned itemflags)
{
int curses_attr;
@@ -641,7 +641,7 @@ mark_synch() -- Don't go beyond this point in I/O on any channel until
for the moment
*/
void
curses_mark_synch()
curses_mark_synch(void)
{
}
@@ -652,7 +652,7 @@ wait_synch() -- Wait until all pending output is complete (*flush*() for
display is OK when return from wait_synch().
*/
void
curses_wait_synch()
curses_wait_synch(void)
{
/* [do we need 'if (counting) curses_count_window((char *)0);' here?] */
}
@@ -700,7 +700,7 @@ print_glyph(window, x, y, glyphinfo, bkglyphinfo)
*/
void
curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y,
curses_print_glyph(winid wid, xchar x, xchar y,
const glyph_info *glyphinfo, const glyph_info *bkglyphinfo UNUSED)
{
int glyph;
@@ -782,7 +782,7 @@ int nhgetch() -- Returns a single character input from the user.
Returned character _must_ be non-zero.
*/
int
curses_nhgetch()
curses_nhgetch(void)
{
int ch;
@@ -828,7 +828,7 @@ nhbell() -- Beep at user. [This will exist at least until sounds are
redone, since sounds aren't attributable to windows anyway.]
*/
void
curses_nhbell()
curses_nhbell(void)
{
beep();
}
@@ -839,7 +839,7 @@ doprev_message()
-- On the tty-port this scrolls WIN_MESSAGE back one line.
*/
int
curses_doprev_message()
curses_doprev_message(void)
{
curses_prev_mesg();
return 0;
@@ -865,7 +865,7 @@ char yn_function(const char *ques, const char *choices, char default)
ports might use a popup.
*/
char
curses_yn_function(const char *question, const char *choices, CHAR_P def)
curses_yn_function(const char *question, const char *choices, char def)
{
return (char) curses_character_input_dialog(question, choices, def);
}
@@ -893,7 +893,7 @@ int get_ext_cmd(void)
selection, -1 otherwise.
*/
int
curses_get_ext_cmd()
curses_get_ext_cmd(void)
{
return curses_ext_cmd();
}
@@ -915,7 +915,7 @@ delay_output() -- Causes a visible delay of 50ms in the output.
by a nap(50ms), but allows asynchronous operation.
*/
void
curses_delay_output()
curses_delay_output(void)
{
/* refreshing the whole display is a waste of time,
* but that's why we're here */
@@ -931,7 +931,7 @@ start_screen() -- Only used on Unix tty ports, but must be declared for
just declare an empty function.
*/
void
curses_start_screen()
curses_start_screen(void)
{
}
@@ -940,7 +940,7 @@ end_screen() -- Only used on Unix tty ports, but must be declared for
completeness. The complement of start_screen().
*/
void
curses_end_screen()
curses_end_screen(void)
{
}
@@ -1024,7 +1024,7 @@ dummy_change_color(int a1 UNUSED, long a2 UNUSED, int a3 UNUSED)
}
static char *
dummy_get_color_string(VOID_ARGS)
dummy_get_color_string(void)
{
return (char *) 0;
}

View File

@@ -242,7 +242,7 @@ curses_block(boolean noscroll) /* noscroll - blocking because of msgtype
}
int
curses_more()
curses_more(void)
{
return curses_block(FALSE);
}
@@ -251,7 +251,7 @@ curses_more()
/* Clear the message window if one line; otherwise unhighlight old messages */
void
curses_clear_unhighlight_message_window()
curses_clear_unhighlight_message_window(void)
{
int mh, mw, count,
brdroffset = curses_window_has_border(MESSAGE_WIN) ? 1 : 0;
@@ -279,7 +279,7 @@ curses_clear_unhighlight_message_window()
recent messages. */
void
curses_last_messages()
curses_last_messages(void)
{
nhprev_mesg *mesg;
int i, height, width;
@@ -324,7 +324,7 @@ curses_last_messages()
/* Initialize list for message history */
void
curses_init_mesg_history()
curses_init_mesg_history(void)
{
max_messages = iflags.msg_history;
@@ -356,7 +356,7 @@ curses_teardown_messages(void)
/* Display previous messages in a popup (via menu so can scroll backwards) */
void
curses_prev_mesg()
curses_prev_mesg(void)
{
int count;
winid wid;
@@ -838,8 +838,7 @@ get_msg_line(boolean reverse, int mindex)
puts it into save file; if any new messages are added to the list while
that is taking place, the results are likely to be scrambled */
char *
curses_getmsghistory(init)
boolean init;
curses_getmsghistory(boolean init)
{
static int nxtidx;
nhprev_mesg *mesg;
@@ -882,9 +881,7 @@ boolean init;
* into message history for ^P recall without having displayed it.
*/
void
curses_putmsghistory(msg, restoring_msghist)
const char *msg;
boolean restoring_msghist;
curses_putmsghistory(const char *msg, boolean restoring_msghist)
{
static boolean initd = FALSE;
static int stash_count;

View File

@@ -19,7 +19,7 @@ void curses_last_messages(void);
void curses_init_mesg_history(void);
void curses_prev_mesg(void);
void curses_count_window(const char *count_text);
char *curses_getmsghistory(BOOLEAN_P);
void curses_putmsghistory(const char *, BOOLEAN_P);
char *curses_getmsghistory(boolean);
void curses_putmsghistory(const char *, boolean);
#endif /* CURSMESG_H */

View File

@@ -38,7 +38,7 @@ static int parse_escape_sequence(void);
/* Read a character of input from the user */
int
curses_read_char()
curses_read_char(void)
{
int ch;
#if defined(ALT_0) || defined(ALT_9) || defined(ALT_A) || defined(ALT_Z)
@@ -624,7 +624,7 @@ curses_move_cursor(winid wid, int x, int y)
/* Perform actions that should be done every turn before nhgetch() */
void
curses_prehousekeeping()
curses_prehousekeeping(void)
{
#ifndef PDCURSES
WINDOW *win = curses_get_nhwin(MAP_WIN);
@@ -647,7 +647,7 @@ curses_prehousekeeping()
/* Perform actions that should be done every turn after nhgetch() */
void
curses_posthousekeeping()
curses_posthousekeeping(void)
{
curs_set(0);
/* curses_decrement_highlights(FALSE); */
@@ -817,8 +817,7 @@ curses_read_attrs(const char *attrs)
/* format iflags.wc2_petattr into "+a+b..." for set bits a, b, ...
(used by core's 'O' command; return value points past leading '+') */
char *
curses_fmt_attrs(outbuf)
char *outbuf;
curses_fmt_attrs(char *outbuf)
{
int attr = iflags.wc2_petattr;
@@ -1030,8 +1029,7 @@ curses_get_mouse(int *mousex, int *mousey, int *mod)
}
void
curses_mouse_support(mode)
int mode; /* 0: off, 1: on, 2: alternate on */
curses_mouse_support(int mode) /* 0: off, 1: on, 2: alternate on */
{
#ifdef NCURSES_MOUSE_VERSION
mmask_t result, oldmask, newmask;

View File

@@ -30,18 +30,18 @@ static int curses_status_colors[MAXBLSTATS];
static int hpbar_percent, hpbar_color;
static int vert_status_dirty;
static void NDECL(draw_status);
static void FDECL(draw_vertical, (BOOLEAN_P));
static void FDECL(draw_horizontal, (BOOLEAN_P));
static void draw_status(void);
static void draw_vertical(boolean);
static void draw_horizontal(boolean);
static void curs_HPbar(char *, int);
static void curs_stat_conds(int, int, int *, int *, char *, boolean *);
static void curs_vert_status_vals(int);
#ifdef STATUS_HILITES
#ifdef TEXTCOLOR
static int FDECL(condcolor, (long, unsigned long *));
static int condcolor(long, unsigned long *);
#endif
static int FDECL(condattr, (long, unsigned long *));
static int FDECL(nhattr2curses, (int));
static int condattr(long, unsigned long *);
static int nhattr2curses(int);
#endif /* STATUS_HILITES */
/* width of a single line in vertical status orientation (one field per line;
@@ -49,7 +49,7 @@ static int FDECL(nhattr2curses, (int));
#define STATVAL_WIDTH 60 /* overkill; was MAXCO (200), massive overkill */
void
curses_status_init()
curses_status_init(void)
{
int i;
@@ -68,7 +68,7 @@ curses_status_init()
}
void
curses_status_finish()
curses_status_finish(void)
{
int i;
@@ -137,11 +137,8 @@ curses_status_finish()
static int changed_fields = 0;
void
curses_status_update(fldidx, ptr, chg, percent, color_and_attr, colormasks)
int fldidx, chg UNUSED,
percent, color_and_attr;
genericptr_t ptr;
unsigned long *colormasks;
curses_status_update(int fldidx, genericptr_t ptr, int chg UNUSED, int percent,
int color_and_attr, unsigned long *colormasks)
{
long *condptr = (long *) ptr;
char *text = (char *) ptr;
@@ -206,7 +203,7 @@ unsigned long *colormasks;
}
static void
draw_status()
draw_status(void)
{
WINDOW *win = curses_get_nhwin(STATUS_WIN);
orient statorient = (orient) curses_get_window_orientation(STATUS_WIN);
@@ -244,8 +241,7 @@ draw_status()
/* horizontal layout on 2 or 3 lines */
static void
draw_horizontal(border)
boolean border;
draw_horizontal(boolean border)
{
#define blPAD BL_FLUSH
/* almost all fields already come with a leading space;
@@ -650,8 +646,7 @@ boolean border;
/* vertical layout, to left or right of map */
static void
draw_vertical(border)
boolean border;
draw_vertical(boolean border)
{
/* for blank lines, the digit prefix is the order in which they get
removed if we need to shrink to fit within height limit (very rare) */
@@ -1258,9 +1253,7 @@ curs_vert_status_vals(int win_width)
* be displayed in based on user settings.
*/
static int
condcolor(bm, bmarray)
long bm;
unsigned long *bmarray;
condcolor(long bm, unsigned long *bmarray)
{
int i;
@@ -1274,9 +1267,7 @@ unsigned long *bmarray;
#endif /* TEXTCOLOR */
static int
condattr(bm, bmarray)
long bm;
unsigned long *bmarray;
condattr(long bm, unsigned long *bmarray)
{
int i, attr = 0;
@@ -1310,8 +1301,7 @@ unsigned long *bmarray;
/* convert tty attributes to curses attributes;
despite similar names, the mask fields have different values */
static int
nhattr2curses(attrmask)
int attrmask;
nhattr2curses(int attrmask)
{
int result = 0;

View File

@@ -17,7 +17,7 @@
/* Global declarations */
void curses_update_stats();
void curses_update_stats(void);
void curses_decrement_highlights(boolean);
attr_t curses_color_attr(int nh_color, int bg_color);

View File

@@ -159,7 +159,7 @@ curses_destroy_win(WINDOW *win)
/* Refresh nethack windows if they exist, or base window if not */
void
curses_refresh_nethack_windows()
curses_refresh_nethack_windows(void)
{
WINDOW *status_window, *message_window, *map_window, *inv_window;
@@ -350,7 +350,7 @@ curses_del_wid(winid wid)
/* called by destroy_nhwindows() prior to exit */
void
curs_destroy_all_wins()
curs_destroy_all_wins(void)
{
curses_count_window((char *) 0); /* clean up orphan */
@@ -683,7 +683,7 @@ curses_draw_map(int sx, int sy, int ex, int ey)
/* Init map array to blanks */
static void
clear_map()
clear_map(void)
{
int x, y;