Apply appropriate #ifdefs and static declarations

This commit is contained in:
Ray Chason
2026-08-19 09:37:41 +03:00
committed by Pasi Kallinen
parent 5883fe4abb
commit cada45a786
6 changed files with 100 additions and 83 deletions
+5 -37
View File
@@ -374,23 +374,15 @@ extern void positionpopup(Widget, boolean);
/* ### winX.c ### */
extern struct xwindow *find_widget(Widget);
extern XColor get_nhcolor(struct xwindow *, int);
extern void init_menu_nhcolors(struct xwindow *);
extern void load_boldfont(struct xwindow *, Widget);
extern Boolean nhApproxColor(Screen *, Colormap, char *, XColor *);
extern Boolean nhCvtStringToPixel(Display *, XrmValuePtr, Cardinal *,
XrmValuePtr, XrmValuePtr, XtPointer *);
extern void get_window_frame_extents(Widget, long *, long *, long *, long *);
extern void get_widget_window_geometry(Widget, int *, int *, int *, int *);
extern char *fontname_boldify(const char *);
extern Dimension nhFontHeight(Widget, int);
extern char key_event_to_char(XKeyEvent *);
extern void msgkey(Widget, XtPointer, XEvent *, Boolean *);
extern void highlight_yn(boolean);
extern void nh_XtPopup(Widget, int, Widget);
extern void nh_XtPopdown(Widget);
extern void win_X11_init(int);
extern void find_scrollbars(Widget, Widget, Widget *, Widget *);
extern void nh_keyscroll(Widget, XEvent *, String *, Cardinal *);
/* ### winmesg.c ### */
extern void set_message_slider(struct xwindow *);
@@ -420,8 +412,6 @@ extern void create_menu_window(struct xwindow *);
extern void destroy_menu_window(struct xwindow *);
/* ### winmisc.c ### */
extern XtPointer i2xtp(int);
extern int xtp2i(XtPointer);
extern void ps_key(Widget, XEvent *, String *,
Cardinal *); /* player selection action */
extern void race_key(Widget, XEvent *, String *,
@@ -442,7 +432,9 @@ extern void release_extended_cmds(void);
/* ### winstatus.c ### */
extern void create_status_window(struct xwindow *, boolean, Widget);
extern void destroy_status_window(struct xwindow *);
#ifndef STATUS_HILITES
extern void adjust_status(struct xwindow *, const char *);
#endif
extern void null_out_status(void);
extern void check_turn_events(void);
#ifdef STATUS_HILITES
@@ -465,7 +457,6 @@ extern void append_text_buffer(struct text_buffer *, const char *,
boolean); /* text buffer routines */
extern void init_text_buffer(struct text_buffer *);
extern void clear_text_buffer(struct text_buffer *);
extern void free_text_buffer(struct text_buffer *);
#ifdef GRAPHIC_TOMBSTONE
extern void calculate_rip_text(int, time_t);
#endif
@@ -481,64 +472,41 @@ extern int get_value_width(Widget);
extern void swap_fg_bg(Widget);
extern void set_value(Widget w, const char *new_value);
/* external declarations */
extern char *X11_getmsghistory(boolean);
extern void X11_putmsghistory(const char *, boolean);
extern void X11_init_nhwindows(int *, char **);
extern void X11_player_selection(void);
extern void X11_askname(void);
extern void X11_get_nh_event(void);
extern void X11_exit_nhwindows(const char *);
extern void X11_suspend_nhwindows(const char *);
extern void X11_resume_nhwindows(void);
extern winid X11_create_nhwindow(int);
extern void X11_clear_nhwindow(winid);
extern void X11_display_nhwindow(winid, boolean);
extern void X11_destroy_nhwindow(winid);
extern void X11_curs(winid, int, int);
extern void X11_putstr(winid, int, const char *);
extern void X11_display_file(const char *, boolean);
extern void X11_start_menu(winid, unsigned long);
extern void X11_add_menu(winid, const glyph_info *, const ANY_P *, char,
char, int, int, const char *, unsigned int);
extern void X11_end_menu(winid, const char *);
extern int X11_select_menu(winid, int, MENU_ITEM_P **);
extern void X11_mark_synch(void);
extern void X11_wait_synch(void);
#ifdef CLIPPING
extern void X11_cliparound(int, int);
#endif
extern void X11_print_glyph(winid, coordxy, coordxy, const glyph_info *,
const glyph_info *);
extern void X11_raw_print(const char *);
extern void X11_raw_print_bold(const char *);
extern int X11_nhgetch(void);
extern int X11_nh_poskey(coordxy *, coordxy *, int *);
extern void X11_nhbell(void);
extern int X11_doprev_message(void);
extern char X11_yn_function_core(const char *, const char *, char, unsigned);
extern char X11_yn_function(const char *, const char *, char);
extern void X11_getlin(const char *, char *);
extern int X11_get_ext_cmd(void);
extern void X11_number_pad(int);
extern void X11_delay_output(void);
extern void X11_status_init(void);
extern void X11_status_finish(void);
extern void X11_status_enablefield(int, const char *, const char *, boolean);
extern void X11_status_update(int, genericptr_t, int, int, int,
unsigned long *);
#ifdef GRAPHIC_TOMBSTONE
extern void X11_outrip(winid, int, time_t);
#else
#ifndef GRAPHIC_TOMBSTONE
extern void genl_outrip(winid, int, time_t);
#endif
extern void X11_preference_update(const char *);
extern void X11_update_inventory(int);
extern win_request_info *X11_ctrl_nhwindow(winid, int, win_request_info *);
extern X11_map_symbol X11_glyph_char(const glyph_info *);
#ifndef USE_XFT
extern XFontStruct *X11_bold_font(Display *, XFontStruct *);
extern XFontStruct *X11_italic_font(Display *, XFontStruct *);
#endif /* !USE_XFT */
#ifdef ENHANCED_SYMBOLS
extern XFontStruct *X11_unicode_font(Display *, XFontStruct *);
#endif
+72 -33
View File
@@ -98,7 +98,7 @@ void (*input_func)(Widget, XEvent *, String *, Cardinal *);
int click_x, click_y, click_button; /* Click position on a map window
* (filled by set_button_values()). */
int updated_inventory; /* used to indicate perm_invent updating */
color_attr X11_menu_promptstyle = { NO_COLOR, ATR_NONE };
static color_attr X11_menu_promptstyle = { NO_COLOR, ATR_NONE };
/* X11/Intrinsic.h prototype has an issue if [[NORETURN]] is used
* rather than the old __attribute((noreturn)) under c23 */
@@ -128,6 +128,41 @@ static XtSignalId X11_sig_id;
#endif
#endif
static void init_menu_nhcolors(struct xwindow *);
static Boolean nhApproxColor(Screen *, Colormap, char *, XColor *);
static Boolean nhCvtStringToPixel(Display *, XrmValuePtr, Cardinal *,
XrmValuePtr, XrmValuePtr, XtPointer *);
static void get_window_frame_extents(Widget, long *, long *, long *, long *);
#ifndef USE_XFT
static char *fontname_boldify(const char *);
#endif
static void msgkey(Widget, XtPointer, XEvent *, Boolean *);
static void nh_keyscroll(Widget, XEvent *, String *, Cardinal *);
static char *X11_getmsghistory(boolean);
static void X11_putmsghistory(const char *, boolean);
static void X11_init_nhwindows(int *, char **);
static void X11_askname(void);
static void X11_get_nh_event(void);
static void X11_suspend_nhwindows(const char *);
static void X11_resume_nhwindows(void);
static void X11_clear_nhwindow(winid);
static void X11_display_nhwindow(winid, boolean);
static void X11_curs(winid, int, int);
static void X11_putstr(winid, int, const char *);
static void X11_display_file(const char *, boolean);
static void X11_mark_synch(void);
static void X11_wait_synch(void);
static void X11_raw_print_bold(const char *);
static int X11_nhgetch(void);
static int X11_nh_poskey(coordxy *, coordxy *, int *);
static int X11_doprev_message(void);
static char X11_yn_function(const char *, const char *, char);
static void X11_number_pad(int);
static void X11_delay_output(void);
static void X11_outrip(winid, int, time_t);
static void X11_preference_update(const char *);
static win_request_info *X11_ctrl_nhwindow(winid, int, win_request_info *);
/* Interface definition, for windows.c */
struct window_procs X11_procs = {
WPID(X11),
@@ -214,7 +249,7 @@ static winid message_win = WIN_ERR, /* These are the winids of the message, */
status_win = WIN_ERR; /* are created in init_windows(). */
static Pixmap icon_pixmap = None; /* Pixmap for icon. */
void
static void
X11_putmsghistory(const char *msg, boolean is_restoring)
{
if (WIN_MESSAGE != WIN_ERR) {
@@ -225,7 +260,7 @@ X11_putmsghistory(const char *msg, boolean is_restoring)
}
}
char *
static char *
X11_getmsghistory(boolean init)
{
if (WIN_MESSAGE != WIN_ERR) {
@@ -308,7 +343,7 @@ get_nhcolor(struct xwindow *wp, int clr)
return wp->nh_colors[0];
}
void
static void
init_menu_nhcolors(struct xwindow *wp)
{
static const char *mapCLR_to_res[CLR_MAX] = {
@@ -392,7 +427,7 @@ init_menu_nhcolors(struct xwindow *wp)
* allocate the exact color, they puke and give you something stupid.
* This is an attempt to find some close readonly cell and use it.
*/
XtConvertArgRec const nhcolorConvertArgs[] = {
static XtConvertArgRec const nhcolorConvertArgs[] = {
{ XtWidgetBaseOffset,
(XtPointer) (ptrdiff_t) XtOffset(Widget, core.screen),
sizeof (Screen *) },
@@ -425,7 +460,7 @@ XtConvertArgRec const nhcolorConvertArgs[] = {
* The approximate color found is returned in color as well.
* Return True if something close was found.
*/
Boolean
static Boolean
nhApproxColor(
Screen *screen, /* screen to use */
Colormap colormap, /* the colormap to use */
@@ -501,7 +536,7 @@ nhApproxColor(
return True;
}
Boolean
static Boolean
nhCvtStringToPixel(
Display *dpy,
XrmValuePtr args, Cardinal *num_args,
@@ -594,7 +629,7 @@ nhCvtStringToPixel(
}
/* Ask the WM for window frame size */
void
static void
get_window_frame_extents(
Widget w,
long *top, long *bottom,
@@ -670,8 +705,9 @@ get_widget_window_geometry(
*y -= top;
}
#ifndef USE_XFT
/* Change the full font name string so the weight is "bold" */
char *
static char *
fontname_boldify(const char *fontname)
{
static char buf[BUFSZ];
@@ -719,6 +755,7 @@ load_boldfont(struct xwindow *wp, Widget w)
fontname = fontname_boldify(XGetAtomName(dpy, (Atom)ret));
wp->boldfs = XLoadQueryFont(dpy, fontname);
}
#endif /* !USE_XFT */
/* ARGSUSED */
static void
@@ -960,13 +997,13 @@ X11_raw_print(const char *str)
(void) puts(str);
}
void
static void
X11_raw_print_bold(const char *str)
{
(void) puts(str);
}
void
static void
X11_curs(winid window, int x, int y)
{
check_winid(window);
@@ -984,7 +1021,7 @@ X11_curs(winid window, int x, int y)
window_list[window].cursy = y;
}
void
static void
X11_putstr(winid window, int attr, const char *str)
{
winid new_win;
@@ -1032,19 +1069,19 @@ X11_putstr(winid window, int attr, const char *str)
}
/* We do event processing as a callback, so this is a null routine. */
void
static void
X11_get_nh_event(void)
{
return;
}
int
static int
X11_nhgetch(void)
{
return input_event(EXIT_ON_KEY_PRESS);
}
int
static int
X11_nh_poskey(coordxy *x, coordxy *y, int *mod)
{
int val = input_event(EXIT_ON_KEY_OR_BUTTON_PRESS);
@@ -1151,7 +1188,7 @@ X11_create_nhwindow(int type)
return window;
}
void
static void
X11_clear_nhwindow(winid window)
{
struct xwindow *wp;
@@ -1177,7 +1214,7 @@ X11_clear_nhwindow(winid window)
}
}
void
static void
X11_display_nhwindow(winid window, boolean blocking)
{
struct xwindow *wp;
@@ -1328,7 +1365,7 @@ X11_update_inventory(int arg)
return;
}
win_request_info *
static win_request_info *
X11_ctrl_nhwindow(
winid window UNUSED,
int request UNUSED,
@@ -1351,7 +1388,7 @@ X11_ctrl_nhwindow(
}
/* The current implementation has all of the saved lines on the screen. */
int
static int
X11_doprev_message(void)
{
return 0;
@@ -1374,7 +1411,7 @@ X11_nhbell(void)
}
}
void
static void
X11_mark_synch(void)
{
if (x_inited) {
@@ -1391,7 +1428,7 @@ X11_mark_synch(void)
}
}
void
static void
X11_wait_synch(void)
{
if (x_inited) {
@@ -1401,13 +1438,13 @@ X11_wait_synch(void)
}
/* Both resume_ and suspend_ are called from ioctl.c and unixunix.c. */
void
static void
X11_resume_nhwindows(void)
{
return;
}
/* ARGSUSED */
void
static void
X11_suspend_nhwindows(const char *str)
{
nhUse(str);
@@ -1417,7 +1454,7 @@ X11_suspend_nhwindows(const char *str)
/* Under X, we don't need to initialize the number pad. */
/* ARGSUSED */
void
static void
X11_number_pad(int state) /* called from options.c */
{
nhUse(state);
@@ -1426,7 +1463,7 @@ X11_number_pad(int state) /* called from options.c */
}
#ifdef GRAPHIC_TOMBSTONE
void
static void
X11_outrip(winid window, int how, time_t when)
{
struct xwindow *wp;
@@ -1597,7 +1634,7 @@ X11_io_error_handler(Display *display)
return 0;
}
void
static void
X11_init_nhwindows(int *argcp, char **argv)
{
int i;
@@ -1812,7 +1849,7 @@ d_timeout(XtPointer client_data, XtIntervalId *id)
* function will send an event to the map window which will be waiting
* for a sent event.
*/
void
static void
X11_delay_output(void)
{
if (!x_inited)
@@ -1902,7 +1939,7 @@ askname_done(Widget w, XtPointer client_data, XtPointer call_data)
/* ask player for character's name to replace generic name "player" (or other
values; see config.h) after 'nethack -u player' or OPTIONS=name:player */
void
static void
X11_askname(void)
{
Widget popup, dialog;
@@ -2120,7 +2157,7 @@ X11_getlin(
/* uses a menu (with no selectors specified) rather than a text window
to allow previous_page and first_menu actions to move backwards */
void
static void
X11_display_file(const char *str, boolean complain)
{
dlb *fp;
@@ -2518,7 +2555,7 @@ X11_yn_function_core(
/* X11-specific edition of yn_function(), the routine called by the core
to show a prompt and get a single key answer, often 'y' vs 'n' */
char
static char
X11_yn_function(
const char *ques, /* prompt text */
const char *choices, /* allowed response chars; any char if Null */
@@ -2531,7 +2568,7 @@ X11_yn_function(
/* used when processing window-capability-specific run-time options;
we support toggling tiles on and off via iflags.wc_tiled_map */
void
static void
X11_preference_update(const char *pref)
{
if (!strcmp(pref, "tiled_map")) {
@@ -2562,7 +2599,7 @@ input_event(int exit_condition)
}
/*ARGSUSED*/
void
static void
msgkey(Widget w, XtPointer data, XEvent *event, Boolean *continue_to_dispatch)
{
Cardinal num = 0;
@@ -2893,7 +2930,7 @@ find_scrollbars(
* Scroll a viewport, using standard NH 1,2,3,4,6,7,8,9 directions.
*/
/*ARGSUSED*/
void
static void
nh_keyscroll(Widget viewport, XEvent *event, String *params,
Cardinal *num_params)
{
@@ -3058,6 +3095,7 @@ X11_glyph_char(const glyph_info *glyphinfo)
#endif
}
#ifndef USE_XFT
/* Given an XFontStruct, return a corresponding bold font */
XFontStruct *
X11_bold_font(Display *display, XFontStruct *font)
@@ -3120,6 +3158,7 @@ X11_italic_font(Display *display, XFontStruct *font)
return font2;
}
#endif /* !USE_XFT */
#ifdef ENHANCED_SYMBOLS
/* Given an XFontStruct, return a corresponding font that supports Unicode */
+3 -3
View File
@@ -89,9 +89,9 @@ static const char menu_entry_translations[] = "#override\n\
<Btn4Down>: scroll(8)\n\
<Btn5Down>: scroll(2)";
XtTranslations menu_entry_translation_table = (XtTranslations) 0;
XtTranslations menu_translation_table = (XtTranslations) 0;
XtTranslations menu_del_translation_table = (XtTranslations) 0;
static XtTranslations menu_entry_translation_table = (XtTranslations) 0;
static XtTranslations menu_translation_table = (XtTranslations) 0;
static XtTranslations menu_del_translation_table = (XtTranslations) 0;
static void
create_menu_translation_tables(void)
+9 -9
View File
@@ -124,13 +124,13 @@ static Widget make_menu(const char *, const char *, const char *, const char *,
const char **, Widget **, XtCallbackProc, Widget *);
/* Bad Hack alert. Using integers instead of XtPointers */
XtPointer
static XtPointer
i2xtp(int i)
{
return (XtPointer) (ptrdiff_t) i;
}
int
static int
xtp2i(XtPointer x)
{
return (int) (ptrdiff_t) x;
@@ -328,15 +328,15 @@ algn_key(Widget w, XEvent *event, String *params, Cardinal *num_params)
exit_x_event = TRUE;
}
int plsel_n_races, plsel_n_roles;
Widget *plsel_race_radios = (Widget *) 0;
Widget *plsel_role_radios = (Widget *) 0;
Widget *plsel_gend_radios = (Widget *) 0;
Widget *plsel_align_radios = (Widget *) 0;
static int plsel_n_races, plsel_n_roles;
static Widget *plsel_race_radios = (Widget *) 0;
static Widget *plsel_role_radios = (Widget *) 0;
static Widget *plsel_gend_radios = (Widget *) 0;
static Widget *plsel_align_radios = (Widget *) 0;
Widget plsel_name_input;
static Widget plsel_name_input;
Widget plsel_btn_play;
static Widget plsel_btn_play;
static void
plsel_dialog_acceptvalues(void)
+8
View File
@@ -123,8 +123,10 @@ static void create_status_window_fancy(struct xwindow *, boolean, Widget);
static void create_status_window_tty(struct xwindow *, boolean, Widget);
static void destroy_status_window_fancy(struct xwindow *);
static void destroy_status_window_tty(struct xwindow *);
#ifndef STATUS_HILITES
static void adjust_status_fancy(struct xwindow *, const char *);
static void adjust_status_tty(struct xwindow *, const char *);
#endif
static void set_percent(int, int, int);
static void tty_status_exposed(Widget, XtPointer, XtPointer);
static void tty_status_redraw(Widget);
@@ -1092,6 +1094,7 @@ destroy_status_window_tty(struct xwindow *wp)
wp->type = NHW_NONE;
}
#ifndef STATUS_HILITES
/*ARGSUSED*/
void
adjust_status_tty(struct xwindow *wp UNUSED, const char *str UNUSED)
@@ -1099,6 +1102,7 @@ adjust_status_tty(struct xwindow *wp UNUSED, const char *str UNUSED)
/* nothing */
return;
}
#endif
void
create_status_window(
@@ -1162,6 +1166,7 @@ destroy_status_window(struct xwindow *wp)
destroy_status_window_tty(wp);
}
#ifndef STATUS_HILITES
void
adjust_status(struct xwindow *wp, const char *str)
{
@@ -1170,6 +1175,7 @@ adjust_status(struct xwindow *wp, const char *str)
else
adjust_status_tty(wp, str);
}
#endif
void
create_status_window_fancy(struct xwindow *wp, /* window pointer */
@@ -1270,6 +1276,7 @@ destroy_status_window_fancy(struct xwindow *wp)
wp->type = NHW_NONE;
}
#ifndef STATUS_HILITES
/*
* This assumes several things:
* + Status has only 2 lines
@@ -1300,6 +1307,7 @@ adjust_status_fancy(struct xwindow *wp, const char *str)
wp->status_information->text.text); num_args++;
XtSetValues(wp->w, args, num_args);
}
#endif
/* Fancy ================================================================== */
extern const char *const hu_stat[]; /* from eat.c */
+3 -1
View File
@@ -59,6 +59,8 @@ static const char rip_translations[] = "#override\n\
static Widget create_ripout_widget(Widget);
#endif
static void free_text_buffer(struct text_buffer *);
/*ARGSUSED*/
void
delete_text(Widget w, XEvent *event, String *params, Cardinal *num_params)
@@ -388,7 +390,7 @@ clear_text_buffer(struct text_buffer *tb)
}
/* Free up allocated memory. */
void
static void
free_text_buffer(struct text_buffer *tb)
{
free(tb->text);