X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Flist_keys.c;h=506f2e845f4cb42d84bb8a1859c8497951d0d996;hp=346878a5bac1c81446d06b3c66c54a6efa390309;hb=119b5a6788c26bf7dcc99fcfd54e072946352a93;hpb=e2e9c09c48b19b24979cafb2d4864f538b5ddd1c diff --git a/test/list_keys.c b/test/list_keys.c index 346878a5..506f2e84 100644 --- a/test/list_keys.c +++ b/test/list_keys.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2016 Free Software Foundation, Inc. * + * Copyright (c) 2016-2018,2019 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: list_keys.c,v 1.17 2016/09/10 21:24:44 tom Exp $ + * $Id: list_keys.c,v 1.25 2019/08/24 23:11:01 tom Exp $ * * Author: Thomas E Dickey * @@ -88,14 +88,14 @@ static int show_key(const char *name, bool show) { int width = 0; - char buffer[10]; - NCURSES_CONST char *value = tigetstr(name); + NCURSES_CONST char *value = tigetstr((NCURSES_CONST char *) name); if (show && t_opt) fputc('"', stdout); if (value != 0 && value != (char *) -1) { while (*value != 0) { + char buffer[10]; int ch = UChar(*value++); switch (ch) { case '\177': @@ -159,7 +159,7 @@ show_key(const char *name, bool show) } static bool -valid_key(const char *name, TERMINAL ** terms, int count) +valid_key(const char *name, TERMINAL **terms, int count) { bool result = FALSE; if (*name == 'k') { @@ -197,8 +197,8 @@ compare_keys(const void *a, const void *b) static void draw_line(int width) { - int j; if (!t_opt) { + int j; for (j = 0; j < width; ++j) { printf("-"); } @@ -209,8 +209,8 @@ draw_line(int width) static const char * modified_key(const char *name) { - static char result[80]; - char buffer[sizeof(result)]; + static char result[100]; + char buffer[sizeof(result) - 10]; int value; char chr; static const char *modifiers[][2] = @@ -238,7 +238,7 @@ modified_key(const char *name) map &= ~6; map |= (bit1 << 1) | (bit2 >> 1); _nc_SPRINTF(result, _nc_SLIMIT(sizeof(result)) - "%sF%d", modifiers[map][f_opt], 1 + key); + "%sF%d", modifiers[map][(unsigned) f_opt], 1 + key); } else if (sscanf(name, "k%[A-Z]%d%c", buffer, &value, &chr) == 2 && (value > 1 && value <= 8) && @@ -253,12 +253,12 @@ modified_key(const char *name) !strcmp(buffer, "NXT") || !strcmp(buffer, "PRV"))) { _nc_SPRINTF(result, _nc_SLIMIT(sizeof(result)) - "%sk%s", modifiers[value - 1][f_opt], buffer); + "%sk%s", modifiers[value - 1][(unsigned) f_opt], buffer); } else if (sscanf(name, "k%[A-Z]%c", buffer, &chr) == 1 && (!strcmp(buffer, "UP") || !strcmp(buffer, "DN"))) { _nc_SPRINTF(result, _nc_SLIMIT(sizeof(result)) - "%sk%s", modifiers[1][f_opt], buffer); + "%sk%s", modifiers[1][(unsigned) f_opt], buffer); } else { *result = '\0'; } @@ -266,7 +266,7 @@ modified_key(const char *name) } static void -list_keys(TERMINAL ** terms, int count) +list_keys(TERMINAL **terms, int count) { int j, k; int widths0 = 0; @@ -285,10 +285,10 @@ list_keys(TERMINAL ** terms, int count) } #if NCURSES_XNAMES if (x_opt) { - TERMTYPE *term; for (k = 0; k < count; ++k) { + TERMTYPE *term; set_curterm(terms[k]); - term = &(cur_term->type); + term = (TERMTYPE *) cur_term; total += (size_t) (NUM_STRINGS(term) - STRCOUNT); } } @@ -298,18 +298,20 @@ list_keys(TERMINAL ** terms, int count) Type(j) = ktOther; if (sscanf(strnames[j], "kf%d", &k) == 1) { Type(j) = ktFunction; - } else if (!strncmp(strnames[j], "kcu", 3)) { + } else if (!(strncmp) (strnames[j], "kcu", 3)) { Type(j) = ktCursor; } Name(j) = strnames[j]; } #if NCURSES_XNAMES if (x_opt) { - TERMTYPE *term; int m, n; + for (k = 0; k < count; ++k) { + TERMTYPE *term; + set_curterm(terms[k]); - term = &(cur_term->type); + term = (TERMTYPE *) cur_term; for (n = STRCOUNT; n < NUM_STRINGS(term); ++n) { bool found = FALSE; const char *estr = ExtStrname(term, (int) n, strnames); @@ -486,6 +488,8 @@ main(int argc, char *argv[]) list_keys(terms, 1); } + free(terms); + ExitProgram(EXIT_SUCCESS); }