]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - progs/tset.c
ncurses 6.0 - patch 20170708
[ncurses.git] / progs / tset.c
index b905ee3c426c2846d902a5dabc115d076b502ad2..d660d84d0f21787787eb24dccaee93a0d1e25bf9 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2015,2016 Free Software Foundation, Inc.              *
+ * Copyright (c) 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            *
@@ -88,6 +88,7 @@
 #include <reset_cmd.h>
 #include <termcap.h>
 #include <transform.h>
+#include <tty_settings.h>
 
 #if HAVE_GETTTYNAM && HAVE_TTYENT_H
 #include <ttyent.h>
@@ -96,7 +97,7 @@
 char *ttyname(int fd);
 #endif
 
-MODULE_ID("$Id: tset.c,v 1.110 2016/08/27 18:06:47 tom Exp $")
+MODULE_ID("$Id: tset.c,v 1.116 2017/01/07 22:48:20 tom Exp $")
 
 #ifndef environ
 extern char **environ;
@@ -106,6 +107,8 @@ const char *_nc_progname = "tset";
 
 #define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
 
+static void exit_error(void) GCC_NORETURN;
+
 static int
 CaselessCmp(const char *a, const char *b)
 {                              /* strcasecmp isn't portable */
@@ -152,7 +155,8 @@ failed(const char *msg)
     } else {
        _nc_STRCPY(temp, "tset: ", sizeof(temp));
     }
-    perror(strncat(temp, msg, sizeof(temp) - strlen(temp) - 2));
+    _nc_STRNCAT(temp, msg, sizeof(temp), sizeof(temp) - strlen(temp) - 2);
+    perror(temp);
     exit_error();
     /* NOTREACHED */
 }
@@ -624,7 +628,7 @@ get_termcap_entry(int fd, char *userarg)
            ttype = askuser(0);
     }
     /* Find the terminfo entry.  If it doesn't exist, ask the user. */
-    while (setupterm((NCURSES_CONST char *) ttype, STDOUT_FILENO, &errret)
+    while (setupterm((NCURSES_CONST char *) ttype, fd, &errret)
           != OK) {
        if (errret == 0) {
            (void) fprintf(stderr, "%s: unknown terminal type %s\n",
@@ -831,9 +835,9 @@ main(int argc, char **argv)
 
     if (same_program(_nc_progname, PROG_RESET)) {
        reset_start(stderr, TRUE, FALSE);
-       reset_tty_settings(&mode);
+       reset_tty_settings(my_fd, &mode);
     } else {
-       reset_start(stderr, FALSE, FALSE);
+       reset_start(stderr, FALSE, TRUE);
     }
 
     ttype = get_termcap_entry(my_fd, *argv);
@@ -841,7 +845,7 @@ main(int argc, char **argv)
     if (!noset) {
 #if HAVE_SIZECHANGE
        if (opt_w) {
-           set_window_size(my_fd, lines, columns);
+           set_window_size(my_fd, &lines, &columns);
        }
 #endif
        if (opt_c) {
@@ -849,7 +853,7 @@ main(int argc, char **argv)
            set_conversions(&mode);
 
            if (!noinit) {
-               if (send_init_strings(&oldmode)) {
+               if (send_init_strings(my_fd, &oldmode)) {
                    (void) putc('\r', stderr);
                    (void) fflush(stderr);
                    (void) napms(1000);         /* Settle the terminal. */