/****************************************************************************
- * 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 *
#include <reset_cmd.h>
#include <termcap.h>
#include <transform.h>
+#include <tty_settings.h>
#if HAVE_GETTTYNAM && HAVE_TTYENT_H
#include <ttyent.h>
char *ttyname(int fd);
#endif
-MODULE_ID("$Id: tset.c,v 1.108 2016/08/20 23:53:44 tom Exp $")
+MODULE_ID("$Id: tset.c,v 1.116 2017/01/07 22:48:20 tom Exp $")
#ifndef environ
extern char **environ;
#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 */
} 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 */
}
#ifdef B57600
DATA("57600", B57600),
#endif
+#ifdef B76800
+ DATA("76800", B57600),
+#endif
#ifdef B115200
DATA("115200", B115200),
#endif
+#ifdef B153600
+ DATA("153600", B153600),
+#endif
#ifdef B230400
DATA("230400", B230400),
#endif
+#ifdef B307200
+ DATA("307200", B307200),
+#endif
#ifdef B460800
DATA("460800", B460800),
#endif
+#ifdef B500000
+ DATA("500000", B500000),
+#endif
+#ifdef B576000
+ DATA("576000", B576000),
+#endif
+#ifdef B921600
+ DATA("921600", B921600),
+#endif
+#ifdef B1000000
+ DATA("1000000", B1000000),
+#endif
+#ifdef B1152000
+ DATA("1152000", B1152000),
+#endif
+#ifdef B1500000
+ DATA("1500000", B1500000),
+#endif
+#ifdef B2000000
+ DATA("2000000", B2000000),
+#endif
+#ifdef B2500000
+ DATA("2500000", B2500000),
+#endif
+#ifdef B3000000
+ DATA("3000000", B3000000),
+#endif
+#ifdef B3500000
+ DATA("3500000", B3500000),
+#endif
+#ifdef B4000000
+ DATA("4000000", B4000000),
+#endif
};
#undef DATA
++rate;
for (n = 0; n < SIZEOF(speeds); ++n) {
+ if (n > 0 && (speeds[n].speed <= speeds[n - 1].speed)) {
+ /* if the speeds are not increasing, likely a numeric overflow */
+ break;
+ }
if (!CaselessCmp(rate, speeds[n].string)) {
sp = speeds + n;
break;
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",
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);
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) {
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. */