aboutsummaryrefslogtreecommitdiff
path: root/test/filter.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/filter.c')
-rw-r--r--test/filter.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/test/filter.c b/test/filter.c
index b7444569b789..7f46820ef280 100644
--- a/test/filter.c
+++ b/test/filter.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2020,2022 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -30,7 +30,7 @@
/*
* Author: Thomas E. Dickey 1998
*
- * $Id: filter.c,v 1.38 2022/12/04 00:40:11 tom Exp $
+ * $Id: filter.c,v 1.43 2025/07/05 15:11:35 tom Exp $
*
* An example of the 'filter()' function in ncurses, this program prompts
* for commands and executes them (like a command shell). It illustrates
@@ -65,7 +65,7 @@ show_prompt(int underline, bool clocked)
if (clocked) {
if (limit >= 3) {
time_t now = time((time_t *) 0);
- struct tm *my = localtime(&now);
+ const struct tm *my = localtime(&now);
char buffer[80];
int skip, y, x;
int margin;
@@ -123,7 +123,7 @@ new_command(char *buffer, int length, int underline, bool clocked, bool polled)
if (first) {
getyx(stdscr, y, x);
first = FALSE;
- } else {
+ } else if (limit > 0) {
int left = 0;
/*
@@ -264,12 +264,12 @@ new_command(char *buffer, int length, int underline, bool clocked, bool polled)
/*
* Cancel xterm's alternate-screen mode (from dialog -TD)
*/
-#define isprivate(s) ((s) != 0 && strstr(s, "\033[?") != 0)
+#define isprivate(s) ((s) != NULL && strstr(s, "\033[?") != NULL)
static void
cancel_altscreen(void)
{
if (isatty(fileno(stdout))
- && key_mouse != 0 /* xterm and kindred */
+ && key_mouse != NULL /* xterm and kindred */
&& isprivate(enter_ca_mode)
&& isprivate(exit_ca_mode)) {
/*
@@ -292,8 +292,8 @@ cancel_altscreen(void)
* implementation of alternate-screen in rxvt, etc., which clear more
* of the display than they should.
*/
- enter_ca_mode = 0;
- exit_ca_mode = 0;
+ enter_ca_mode = NULL;
+ exit_ca_mode = NULL;
}
}
#endif
@@ -310,7 +310,7 @@ usage(int ok)
#ifdef NCURSES_VERSION
," -a suppress xterm alternate-screen by amending smcup/rmcup"
#endif
- ," -c show current time on prompt line with \"Command\""
+ ," -t show current time on prompt line with \"Command\""
#if HAVE_USE_DEFAULT_COLORS
," -d invoke use_default_colors"
#endif
@@ -335,7 +335,7 @@ main(int argc, char *argv[])
#ifdef NCURSES_VERSION
bool a_option = FALSE;
#endif
- bool c_option = FALSE;
+ bool t_option = FALSE;
#if HAVE_USE_DEFAULT_COLORS
bool d_option = FALSE;
#endif
@@ -344,15 +344,15 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
- while ((ch = getopt(argc, argv, OPTS_COMMON "adcip")) != -1) {
+ while ((ch = getopt(argc, argv, OPTS_COMMON "adtip")) != -1) {
switch (ch) {
#ifdef NCURSES_VERSION
case 'a':
a_option = TRUE;
break;
#endif
- case 'c':
- c_option = TRUE;
+ case 't':
+ t_option = TRUE;
break;
#if HAVE_USE_DEFAULT_COLORS
case 'd':
@@ -365,11 +365,8 @@ main(int argc, char *argv[])
case 'p':
p_option = TRUE;
break;
- case OPTS_VERSION:
- show_version(argv);
- ExitProgram(EXIT_SUCCESS);
default:
- usage(ch == OPTS_USAGE);
+ CASE_COMMON;
/* NOTREACHED */
}
}
@@ -380,7 +377,7 @@ main(int argc, char *argv[])
if (i_option) {
initscr();
} else {
- if (newterm((char *) 0, stdout, stdin) == 0) {
+ if (newterm((char *) 0, stdout, stdin) == NULL) {
fprintf(stderr, "cannot initialize terminal\n");
ExitProgram(EXIT_FAILURE);
}
@@ -408,7 +405,7 @@ main(int argc, char *argv[])
for (;;) {
int code = new_command(buffer, sizeof(buffer) - 1,
- underline, c_option, p_option);
+ underline, t_option, p_option);
if (code == ERR || *buffer == '\0')
break;
reset_shell_mode();