]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - progs/tput.c
ncurses 6.2 - patch 20200212
[ncurses.git] / progs / tput.c
index 76370cbcb74cc8cb3355da93d041d67a17935a03..295b83fb8161513a83697cf0ee9da2ff8c135af2 100644 (file)
@@ -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 <transform.h>
 #include <tty_settings.h>
 
-MODULE_ID("$Id: tput.c,v 1.77 2017/10/07 23:51:01 tom Exp $")
+MODULE_ID("$Id: tput.c,v 1.81 2020/02/02 23:34:34 tom Exp $")
 
 #define PUTS(s)                fputs(s, stdout)
 
@@ -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);
@@ -293,7 +294,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 +317,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.