summaryrefslogtreecommitdiff
path: root/test/demo_altkeys.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2026-01-14 13:37:49 +0100
committerBaptiste Daroussin <bapt@FreeBSD.org>2026-01-14 13:37:49 +0100
commitc5a1e08b52b2f6c05e0116d46277904b711b6bdb (patch)
treea6ad7350d1b1100356ca59616d22c51dd29743eb /test/demo_altkeys.c
parent24fa7a5107c5b75d1c197accf0305be64bc72882 (diff)
Vendor import ncurses 6.6vendor/ncurses/6.6vendor/ncurses
Diffstat (limited to 'test/demo_altkeys.c')
-rw-r--r--test/demo_altkeys.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/test/demo_altkeys.c b/test/demo_altkeys.c
index ea6a7e64bcae..a165ffb3fcab 100644
--- a/test/demo_altkeys.c
+++ b/test/demo_altkeys.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2005-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -27,7 +27,7 @@
* authorization. *
****************************************************************************/
/*
- * $Id: demo_altkeys.c,v 1.17 2023/02/25 18:08:02 tom Exp $
+ * $Id: demo_altkeys.c,v 1.20 2025/07/05 15:11:35 tom Exp $
*
* Demonstrate the define_key() function.
* Thomas Dickey - 2005/10/22
@@ -49,7 +49,7 @@ log_last_line(WINDOW *win)
{
FILE *fp;
- if ((fp = fopen(MY_LOGFILE, "a")) != 0) {
+ if ((fp = fopen(MY_LOGFILE, "a")) != NULL) {
char temp[256];
int y, x, n;
int need = sizeof(temp) - 1;
@@ -100,11 +100,8 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
switch (ch) {
- case OPTS_VERSION:
- show_version(argv);
- ExitProgram(EXIT_SUCCESS);
default:
- usage(ch == OPTS_USAGE);
+ CASE_COMMON;
/* NOTREACHED */
}
}
@@ -114,7 +111,7 @@ main(int argc, char *argv[])
unlink(MY_LOGFILE);
setlocale(LC_ALL, "");
- if (newterm(0, stdout, stdin) == 0) {
+ if (newterm(NULL, stdout, stdin) == NULL) {
fprintf(stderr, "Cannot initialize terminal\n");
ExitProgram(EXIT_FAILURE);
}
@@ -135,12 +132,14 @@ main(int argc, char *argv[])
}
for (n = KEY_MIN; n < KEY_MAX; ++n) {
char *value;
- if ((value = keybound(n, 0)) != 0) {
+ if ((value = keybound(n, 0)) != NULL) {
size_t need = strlen(value) + 2;
char *temp = typeMalloc(char, need);
- _nc_SPRINTF(temp, _nc_SLIMIT(need) "\033%s", value);
- define_key(temp, n + MY_KEYS);
- free(temp);
+ if (temp != NULL) {
+ _nc_SPRINTF(temp, _nc_SLIMIT(need) "\033%s", value);
+ define_key(temp, n + MY_KEYS);
+ free(temp);
+ }
free(value);
}
}
@@ -158,7 +157,7 @@ main(int argc, char *argv[])
printw("Keycode %d, name %s%s\n",
ch,
escaped ? "ESC-" : "",
- name != 0 ? name : "<null>");
+ name != NULL ? name : "<null>");
log_last_line(stdscr);
clrtoeol();
if (ch == 'q')