X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftput.c;h=4bb771478d255964d7cd46d743c5224f1649d5ee;hp=76370cbcb74cc8cb3355da93d041d67a17935a03;hb=73dd18dba5148d708638caa25c085d82f704e972;hpb=cd142df6d9934f1bda19f5b968cc666291be5072 diff --git a/progs/tput.c b/progs/tput.c index 76370cbc..4bb77147 100644 --- a/progs/tput.c +++ b/progs/tput.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. * + * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -50,7 +51,7 @@ #include #include -MODULE_ID("$Id: tput.c,v 1.77 2017/10/07 23:51:01 tom Exp $") +MODULE_ID("$Id: tput.c,v 1.83 2020/05/27 23:47:51 tom Exp $") #define PUTS(s) fputs(s, stdout) @@ -62,7 +63,7 @@ static bool is_reset = FALSE; static bool is_clear = FALSE; static void -quit(int status, const char *fmt,...) +quit(int status, const char *fmt, ...) { va_list argp; @@ -230,7 +231,7 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[]) * representations */ - for (k = 1; k < argc; k++) { + for (k = 1; (k < argc) && (k < NUM_PARM); k++) { char *tmp = 0; strings[k] = argv[k]; numbers[k] = strtol(argv[k], &tmp, 0); @@ -250,6 +251,19 @@ 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; 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]) @@ -263,6 +277,7 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[]) myParam(7), myParam(8), myParam(9)); +#undef myParam break; } } @@ -293,7 +308,7 @@ main(int argc, char **argv) term = getenv("TERM"); - while ((c = getopt(argc, argv, "ST:V")) != -1) { + while ((c = getopt(argc, argv, "ST:Vx")) != -1) { switch (c) { case 'S': cmdline = FALSE; @@ -316,7 +331,10 @@ main(int argc, char **argv) } is_alias = (is_clear || is_reset || is_init); - need_tty = (is_reset || is_init); + need_tty = ((is_reset || is_init) || + (optind < argc && + (!strcmp(argv[optind], "reset") || + !strcmp(argv[optind], "init")))); /* * Modify the argument list to omit the options we processed.