X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Flist_keys.c;fp=test%2Flist_keys.c;h=87c04c970cd20e3a94c5b03489cca9009b19039f;hp=b43dd37ab73f324ff5cecbc77937b329e68337ff;hb=3353ecc7ed0f1d3b4e6c7e8e98d92f469d593e35;hpb=3e0f770501852be3a2cb05d8044219d7b04dbfad diff --git a/test/list_keys.c b/test/list_keys.c index b43dd37a..87c04c97 100644 --- a/test/list_keys.c +++ b/test/list_keys.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: list_keys.c,v 1.9 2016/06/18 22:18:30 tom Exp $ + * $Id: list_keys.c,v 1.12 2016/07/02 23:45:53 tom Exp $ * * Author: Thomas E Dickey * @@ -88,7 +88,7 @@ show_key(const char *name, bool show) { int width = 0; char buffer[10]; - char *value = tigetstr(name); + NCURSES_CONST char *value = tigetstr(name); if (show && t_opt) fputc('"', stdout); @@ -329,6 +329,7 @@ list_keys(TERMINAL ** terms, int count) printf("\n"); } } + free(list); } static void @@ -358,7 +359,7 @@ int main(int argc, char *argv[]) { int n; - TERMINAL **terms = typeCalloc(TERMINAL *, argc); + TERMINAL **terms = typeCalloc(TERMINAL *, argc + 1); while ((n = getopt(argc, argv, "ftx")) != -1) { switch (n) { @@ -383,11 +384,22 @@ main(int argc, char *argv[]) use_extended_names(x_opt); #endif - for (n = optind; n < argc; ++n) { - setupterm((NCURSES_CONST char *) argv[n], 1, (int *) 0); - terms[n - optind] = cur_term; + if (optind < argc) { + int found = 0; + int status; + for (n = optind; n < argc; ++n) { + setupterm((NCURSES_CONST char *) argv[n], 1, &status); + if (status > 0 && cur_term != 0) { + terms[found++] = cur_term; + } + } + if (found) + list_keys(terms, found); + } else { + setupterm(NULL, 1, (int *) 0); + terms[0] = cur_term; + list_keys(terms, 1); } - list_keys(terms, argc - optind); ExitProgram(EXIT_SUCCESS); }