curses lint

This commit is contained in:
PatR
2018-12-26 01:45:17 -08:00
parent cae50298b6
commit ceb446eaea
4 changed files with 44 additions and 40 deletions

View File

@@ -87,17 +87,10 @@ curses_line_input_dialog(const char *prompt, char *answer, int buffer)
int prompt_width = strlen(prompt) + buffer + 1; int prompt_width = strlen(prompt) + buffer + 1;
int prompt_height = 1; int prompt_height = 1;
int height = prompt_height; int height = prompt_height;
#if __STDC_VERSION__ >= 199901L
char input[buffer];
#else
#ifndef BUFSZ
#define BUFSZ 256
#endif
char input[BUFSZ]; char input[BUFSZ];
buffer = BUFSZ - 1; if (buffer >= (int) sizeof input)
#endif buffer = (int) sizeof input - 1;
maxwidth = term_cols - 2; maxwidth = term_cols - 2;
if (iflags.window_inited) { if (iflags.window_inited) {
@@ -164,7 +157,9 @@ curses_character_input_dialog(const char *prompt, const char *choices,
CHAR_P def) CHAR_P def)
{ {
WINDOW *askwin = NULL; WINDOW *askwin = NULL;
#ifdef PDCURSES
WINDOW *message_window; WINDOW *message_window;
#endif
int answer, count, maxwidth, map_height, map_width; int answer, count, maxwidth, map_height, map_width;
char *linestr; char *linestr;
char askstr[BUFSZ + QBUFSZ]; char askstr[BUFSZ + QBUFSZ];
@@ -518,8 +513,8 @@ curses_add_nhmenu_item(winid wid, int glyph, const ANY_P * identifier,
nhmenu *current_menu = get_menu(wid); nhmenu *current_menu = get_menu(wid);
if (current_menu == NULL) { if (current_menu == NULL) {
impossible impossible(
("curses_add_nhmenu_item: attempt to add item to nonexistent menu"); "curses_add_nhmenu_item: attempt to add item to nonexistent menu");
return; return;
} }
@@ -568,21 +563,19 @@ void
curses_finalize_nhmenu(winid wid, const char *prompt) curses_finalize_nhmenu(winid wid, const char *prompt)
{ {
int count = 0; int count = 0;
nhmenu_item *menu_item_ptr;
nhmenu *current_menu = get_menu(wid); nhmenu *current_menu = get_menu(wid);
if (current_menu == NULL) { if (current_menu == NULL) {
impossible("curses_finalize_nhmenu: attempt to finalize nonexistent menu"); impossible(
"curses_finalize_nhmenu: attempt to finalize nonexistent menu");
return; return;
} }
for (menu_item_ptr = current_menu->entries;
nhmenu_item *menu_item_ptr = current_menu->entries; menu_item_ptr != NULL; menu_item_ptr = menu_item_ptr->next_item)
while (menu_item_ptr != NULL) {
menu_item_ptr = menu_item_ptr->next_item;
count++; count++;
}
current_menu->num_entries = count; current_menu->num_entries = count;
current_menu->prompt = curses_copy_of(prompt); current_menu->prompt = curses_copy_of(prompt);
} }
@@ -601,7 +594,8 @@ curses_display_nhmenu(winid wid, int how, MENU_ITEM_P ** _selected)
*_selected = NULL; *_selected = NULL;
if (current_menu == NULL) { if (current_menu == NULL) {
impossible("curses_display_nhmenu: attempt to display nonexistent menu"); impossible(
"curses_display_nhmenu: attempt to display nonexistent menu");
return '\033'; return '\033';
} }
@@ -1021,7 +1015,7 @@ menu_display_page(nhmenu *menu, WINDOW * win, int page_num)
start_col += 4; start_col += 4;
} }
#if 0 #if 0
//FIXME: menuglyphs not implemented yet /* FIXME: menuglyphs not implemented yet */
if (menu_item_ptr->glyph != NO_GLYPH && iflags.use_menu_glyphs) { if (menu_item_ptr->glyph != NO_GLYPH && iflags.use_menu_glyphs) {
unsigned special; /*notused */ unsigned special; /*notused */

View File

@@ -62,14 +62,15 @@ curses_update_inv(void)
/* Adds an inventory item. */ /* Adds an inventory item. */
void void
curses_add_inv(int y, int glyph, CHAR_P accelerator, attr_t attr, curses_add_inv(int y,
const char *str) int glyph UNUSED,
CHAR_P accelerator, attr_t attr, const char *str)
{ {
WINDOW *win = curses_get_nhwin(INV_WIN); WINDOW *win = curses_get_nhwin(INV_WIN);
int color = NO_COLOR; int color = NO_COLOR;
int x = 0;
/* Figure out where to draw the line */ /* Figure out where to draw the line */
int x = 0;
if (curses_window_has_border(INV_WIN)) { if (curses_window_has_border(INV_WIN)) {
x++; x++;
y++; y++;
@@ -78,6 +79,7 @@ curses_add_inv(int y, int glyph, CHAR_P accelerator, attr_t attr,
wmove(win, y, x); wmove(win, y, x);
if (accelerator) { if (accelerator) {
attr_t bold = A_BOLD; attr_t bold = A_BOLD;
wattron(win, bold); wattron(win, bold);
waddch(win, accelerator); waddch(win, accelerator);
wattroff(win, bold); wattroff(win, bold);
@@ -88,17 +90,20 @@ curses_add_inv(int y, int glyph, CHAR_P accelerator, attr_t attr,
unsigned dummy = 0; /* Not used */ unsigned dummy = 0; /* Not used */
int color = 0; int color = 0;
int symbol = 0; int symbol = 0;
attr_t glyphclr;
mapglyph(glyph, &symbol, &color, &dummy, mapglyph(glyph, &symbol, &color, &dummy,
u.ux, u.uy); u.ux, u.uy);
attr_t glyphclr = curses_color_attr(color, 0); glyphclr = curses_color_attr(color, 0);
wattron(win, glyphclr); wattron(win, glyphclr);
wprintw(win, "%c ", symbol); wprintw(win, "%c ", symbol);
wattroff(win, glyphclr); wattroff(win, glyphclr);
} }
#endif #endif
if (accelerator && /* Don't colorize categories */ if (accelerator /* Don't colorize categories */
iflags.use_menu_color) { && iflags.use_menu_color) {
char str_mutable[BUFSZ]; char str_mutable[BUFSZ];
Strcpy(str_mutable, str); Strcpy(str_mutable, str);
attr = 0; attr = 0;
get_menu_coloring(str_mutable, &color, (int *) &attr); get_menu_coloring(str_mutable, &color, (int *) &attr);

View File

@@ -14,14 +14,14 @@
/* Interface definition, for windows.c */ /* Interface definition, for windows.c */
struct window_procs curses_procs = { struct window_procs curses_procs = {
"curses", "curses",
WC_ALIGN_MESSAGE | WC_ALIGN_STATUS | WC_COLOR | WC_HILITE_PET | (WC_ALIGN_MESSAGE | WC_ALIGN_STATUS | WC_COLOR | WC_HILITE_PET
WC_PERM_INVENT | WC_POPUP_DIALOG | WC_SPLASH_SCREEN, | WC_PERM_INVENT | WC_POPUP_DIALOG | WC_SPLASH_SCREEN),
WC2_DARKGRAY | WC2_HITPOINTBAR | (WC2_DARKGRAY | WC2_HITPOINTBAR
#if defined(STATUS_HILITES) #if defined(STATUS_HILITES)
WC2_HILITE_STATUS | | WC2_HILITE_STATUS
#endif #endif
WC2_HITPOINTBAR | WC2_FLUSH_STATUS | | WC2_HITPOINTBAR | WC2_FLUSH_STATUS
WC2_TERM_SIZE | WC2_WINDOWBORDERS | WC2_PETATTR | WC2_GUICOLOR, | WC2_TERM_SIZE | WC2_WINDOWBORDERS | WC2_PETATTR | WC2_GUICOLOR),
curses_init_nhwindows, curses_init_nhwindows,
curses_player_selection, curses_player_selection,
curses_askname, curses_askname,
@@ -110,7 +110,8 @@ init_nhwindows(int* argcp, char** argv)
** windows? Or at least all but WIN_INFO? -dean ** windows? Or at least all but WIN_INFO? -dean
*/ */
void void
curses_init_nhwindows(int *argcp, char **argv) curses_init_nhwindows(int *argcp UNUSED,
char **argv UNUSED)
{ {
#ifdef PDCURSES #ifdef PDCURSES
char window_title[BUFSZ]; char window_title[BUFSZ];
@@ -249,7 +250,7 @@ curses_exit_nhwindows(const char *str)
/* Prepare the window to be suspended. */ /* Prepare the window to be suspended. */
void void
curses_suspend_nhwindows(const char *str) curses_suspend_nhwindows(const char *str UNUSED)
{ {
endwin(); endwin();
} }
@@ -575,7 +576,8 @@ print_glyph(window, x, y, glyph, bkglyph)
It's not used here. It's not used here.
*/ */
void void
curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y, int glyph, int bkglyph) curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y, int glyph,
int bkglyph UNUSED)
{ {
int ch; int ch;
int color; int color;
@@ -767,8 +769,9 @@ number_pad(state)
-- Initialize the number pad to the given state. -- Initialize the number pad to the given state.
*/ */
void void
curses_number_pad(int state) curses_number_pad(int state UNUSED)
{ {
return;
} }
/* /*
@@ -812,8 +815,10 @@ outrip(winid, int)
genl_outrip for the value and check the #if in rip.c. genl_outrip for the value and check the #if in rip.c.
*/ */
void void
curses_outrip(winid wid, int how) curses_outrip(winid wid UNUSED,
int how UNUSED)
{ {
return;
} }
/* /*

View File

@@ -143,8 +143,7 @@ curses_block(boolean noscroll)
{ {
int height, width, ret = 0; int height, width, ret = 0;
WINDOW *win = curses_get_nhwin(MESSAGE_WIN); WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
char *resp = " \r\n\033"; /* space, enter, esc */ const char *resp = " \r\n\033"; /* space, enter, esc */
curses_get_window_size(MESSAGE_WIN, &height, &width); curses_get_window_size(MESSAGE_WIN, &height, &width);
curses_toggle_color_attr(win, MORECOLOR, NONE, ON); curses_toggle_color_attr(win, MORECOLOR, NONE, ON);
@@ -154,7 +153,8 @@ curses_block(boolean noscroll)
/* msgtype=stop should require space/enter rather than /* msgtype=stop should require space/enter rather than
* just any key, as we want to prevent YASD from * just any key, as we want to prevent YASD from
* riding direction keys. */ * riding direction keys. */
while ((ret = wgetch(win)) && !index(resp,(char)ret)); while ((ret = wgetch(win)) != 0 && !index(resp, (char) ret))
continue;
if (height == 1) { if (height == 1) {
curses_clear_unhighlight_message_window(); curses_clear_unhighlight_message_window();
} else { } else {