check if capname is NULL for tparm() - sfeed_curses - sfeed curses UI (now part… | |
git clone git://git.codemadness.org/sfeed_curses | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit ea54b7b64b9a9c92108a2e1c680c426ca248e9cd | |
parent 8ebfb75d9ca26ce24a76aa3dc956182bd06f5b59 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Sun, 25 Jul 2021 14:36:53 +0200 | |
check if capname is NULL for tparm() | |
POSIX also does not specify NULL is allowed or not, so assume it isn't. | |
https://pubs.opengroup.org/onlinepubs/7908799/xcurses/tigetflag.html | |
This adds a wrapper to prevent NULL assertion in NetBSD curses/terminfo. | |
netbsd-curses can use a diagnostic assert and aborts the program: | |
https://github.com/oasislinux/netbsd-curses/blob/5b78297a1276a7d64c3be7… | |
http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/lib/libterminfo/tpar… | |
The current ncurses snapshot can show a trace call when the parameter is NULL, | |
see the tparm_setup() function: | |
https://github.com/ThomasDickey/ncurses-snapshots/blob/master/ncurses/t… | |
OpenBSD ncurses (older version), tparam_internal function does nothing if the p… | |
http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/lib/libcurses/t… | |
Noticed on Oasis Linux which uses netbsd-curses and aborts when used in the | |
terminal with the default $TERM=linux . | |
Diffstat: | |
M sfeed_curses.c | 32 ++++++++++++++++++++---------… | |
1 file changed, 21 insertions(+), 11 deletions(-) | |
--- | |
diff --git a/sfeed_curses.c b/sfeed_curses.c | |
@@ -272,6 +272,16 @@ estrdup(const char *s) | |
return p; | |
} | |
+/* wrapper for tparm which allows NULL parameter for str. */ | |
+char * | |
+tparmnull(const char *str, long p1, long p2, long p3, long p4, long p5, | |
+ long p6, long p7, long p8, long p9) | |
+{ | |
+ if (!str) | |
+ return NULL; | |
+ return tparm(str, p1, p2, p3, p4, p5, p6, p7, p8, p9); | |
+} | |
+ | |
/* strcasestr() included for portability */ | |
#undef strcasestr | |
char * | |
@@ -508,7 +518,7 @@ updatetitle(void) | |
void | |
appmode(int on) | |
{ | |
- ttywrite(tparm(on ? enter_ca_mode : exit_ca_mode, 0, 0, 0, 0, 0, 0, 0,… | |
+ ttywrite(tparmnull(on ? enter_ca_mode : exit_ca_mode, 0, 0, 0, 0, 0, 0… | |
} | |
void | |
@@ -521,13 +531,13 @@ mousemode(int on) | |
void | |
cursormode(int on) | |
{ | |
- ttywrite(tparm(on ? cursor_normal : cursor_invisible, 0, 0, 0, 0, 0, 0… | |
+ ttywrite(tparmnull(on ? cursor_normal : cursor_invisible, 0, 0, 0, 0, … | |
} | |
void | |
cursormove(int x, int y) | |
{ | |
- ttywrite(tparm(cursor_address, y, x, 0, 0, 0, 0, 0, 0, 0)); | |
+ ttywrite(tparmnull(cursor_address, y, x, 0, 0, 0, 0, 0, 0, 0)); | |
} | |
void | |
@@ -535,7 +545,7 @@ cursorsave(void) | |
{ | |
/* do not save the cursor if it won't be restored anyway */ | |
if (cursor_invisible) | |
- ttywrite(tparm(save_cursor, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
+ ttywrite(tparmnull(save_cursor, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
} | |
void | |
@@ -543,7 +553,7 @@ cursorrestore(void) | |
{ | |
/* if the cursor cannot be hidden then move to a consistent position */ | |
if (cursor_invisible) | |
- ttywrite(tparm(restore_cursor, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
+ ttywrite(tparmnull(restore_cursor, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
else | |
cursormove(0, 0); | |
} | |
@@ -553,16 +563,16 @@ attrmode(int mode) | |
{ | |
switch (mode) { | |
case ATTR_RESET: | |
- ttywrite(tparm(exit_attribute_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0)… | |
+ ttywrite(tparmnull(exit_attribute_mode, 0, 0, 0, 0, 0, 0, 0, 0… | |
break; | |
case ATTR_BOLD_ON: | |
- ttywrite(tparm(enter_bold_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
+ ttywrite(tparmnull(enter_bold_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0)… | |
break; | |
case ATTR_FAINT_ON: | |
- ttywrite(tparm(enter_dim_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
+ ttywrite(tparmnull(enter_dim_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
break; | |
case ATTR_REVERSE_ON: | |
- ttywrite(tparm(enter_reverse_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
+ ttywrite(tparmnull(enter_reverse_mode, 0, 0, 0, 0, 0, 0, 0, 0,… | |
break; | |
default: | |
break; | |
@@ -572,13 +582,13 @@ attrmode(int mode) | |
void | |
cleareol(void) | |
{ | |
- ttywrite(tparm(clr_eol, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
+ ttywrite(tparmnull(clr_eol, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
} | |
void | |
clearscreen(void) | |
{ | |
- ttywrite(tparm(clear_screen, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
+ ttywrite(tparmnull(clear_screen, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
} | |
void |