X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=test%2Flist_keys.c;h=96b02e14f355e29fcb448dc6ce003720a936dd0a;hb=91494ab0071e71177728916199a406768f5ef963;hp=ee54b856998fb0ad44f2af758ab965fc3a40d648;hpb=f79c210479470378389aab5b8d4d42d4a7f3d9a4;p=ncurses.git diff --git a/test/list_keys.c b/test/list_keys.c index ee54b856..96b02e14 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.32 2023/06/24 13:57:11 tom Exp $ * * Author: Thomas E Dickey * @@ -71,6 +71,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 +345,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; }