X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftput.c;h=8ca363cb9ffdbdd1348e83c6580f3d514e874202;hp=295b83fb8161513a83697cf0ee9da2ff8c135af2;hb=6830dca51a4e50d41e7bd114bdbaa857b42a46f4;hpb=47d2fb4537d9ad5bb14f4810561a327930ca4280 diff --git a/progs/tput.c b/progs/tput.c index 295b83fb..8ca363cb 100644 --- a/progs/tput.c +++ b/progs/tput.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -51,7 +51,7 @@ #include #include -MODULE_ID("$Id: tput.c,v 1.81 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: tput.c,v 1.86 2021/03/20 23:46:57 tom Exp $") #define PUTS(s) fputs(s, stdout) @@ -62,8 +62,8 @@ static bool is_init = FALSE; static bool is_reset = FALSE; static bool is_clear = FALSE; -static void -quit(int status, const char *fmt,...) +static GCC_NORETURN void +quit(int status, const char *fmt, ...) { va_list argp; @@ -75,7 +75,7 @@ quit(int status, const char *fmt,...) ExitProgram(status); } -static void +static GCC_NORETURN void usage(void) { #define KEEP(s) s "\n" @@ -225,6 +225,7 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[]) long numbers[1 + NUM_PARM]; char *strings[1 + NUM_PARM]; char *p_is_s[NUM_PARM]; + TParams paramType; /* Nasty hack time. The tparm function needs to see numeric * parameters as numbers, not as pointers to their string @@ -243,7 +244,21 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[]) strings[k] = 0; } - switch (tparm_type(name)) { + paramType = tparm_type(name); +#if NCURSES_XNAMES + /* + * If the capability is an extended one, analyze the string. + */ + if (paramType == Numbers) { + struct name_table_entry const *entry_ptr; + entry_ptr = _nc_find_type_entry(name, STRING, FALSE); + if (entry_ptr == NULL) { + paramType = Other; + } + } +#endif + + switch (paramType) { case Num_Str: s = TPARM_2(s, numbers[1], strings[2]); break; @@ -251,6 +266,21 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[]) s = TPARM_3(s, numbers[1], strings[2], strings[3]); break; case Numbers: +#define myParam(n) numbers[n] + s = TIPARM_9(s, + myParam(1), + myParam(2), + myParam(3), + myParam(4), + myParam(5), + myParam(6), + myParam(7), + myParam(8), + myParam(9)); +#undef myParam + break; + case Other: + /* FALLTHRU */ default: (void) _nc_tparm_analyze(s, p_is_s, &ignored); #define myParam(n) (p_is_s[n - 1] != 0 ? ((TPARM_ARG) strings[n]) : numbers[n]) @@ -264,6 +294,7 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[]) myParam(7), myParam(8), myParam(9)); +#undef myParam break; } }