X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=test%2Flist_keys.c;h=b616919f4653c0a5b92bc7deb148b9aece0b249f;hb=122d3739b3c11c83decc625d53f26fff6e825710;hp=ee54b856998fb0ad44f2af758ab965fc3a40d648;hpb=a09e8b13568e210a03ca4ad64e8552c0edea07c5;p=ncurses.git diff --git a/test/list_keys.c b/test/list_keys.c index ee54b856..b616919f 100644 --- a/test/list_keys.c +++ b/test/list_keys.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2021,2022 Thomas E. Dickey * + * Copyright 2018-2022,2023 Thomas E. Dickey * * Copyright 2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: list_keys.c,v 1.31 2022/12/10 23:23:27 tom Exp $ + * $Id: list_keys.c,v 1.33 2023/11/11 00:35:05 tom Exp $ * * Author: Thomas E Dickey * @@ -52,7 +52,10 @@ static bool f_opt = FALSE; static bool m_opt = FALSE; static bool t_opt = FALSE; + +#if NCURSES_XNAMES || HAVE_USE_EXTENDED_NAMES static bool x_opt = FALSE; +#endif typedef enum { ktCursor @@ -71,6 +74,13 @@ typedef struct { #define Type(n) list[n].type #define Name(n) list[n].name +static void +failed(const char *msg) +{ + perror(msg); + ExitProgram(EXIT_FAILURE); +} + static const char * full_name(const char *name) { @@ -338,8 +348,11 @@ list_keys(TERMINAL **terms, int count) widths1 = (int) strlen(modifier); for (k = 0; k < count; ++k) { + char *value; set_curterm(terms[k]); - check = (int) strlen(termname()); + if ((value = termname()) == NULL) + failed("termname"); + check = (int) strlen(value); if (widths2 < check) widths2 = check; } @@ -461,7 +474,7 @@ main(int argc, char *argv[]) case 't': t_opt = TRUE; break; -#ifdef NCURSES_VERSION +#if NCURSES_XNAMES || HAVE_USE_EXTENDED_NAMES case 'x': x_opt = TRUE; break;