X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftset.c;h=f21cb6d731f330948a9703b0c1c543ac33731ec7;hp=7a0f521ec2b1304bf75ec77900cdc910556cd5be;hb=1dd25cc0259e0683290fe889707b04979b5fda0a;hpb=29a36e53e1f77a0c3672f2e267d573823d6a9a60 diff --git a/progs/tset.c b/progs/tset.c index 7a0f521e..f21cb6d7 100644 --- a/progs/tset.c +++ b/progs/tset.c @@ -96,7 +96,7 @@ 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.113 2016/10/22 23:34:47 tom Exp $") #ifndef environ extern char **environ; @@ -106,6 +106,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 +154,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 */ } @@ -273,15 +276,57 @@ static const SPEEDS speeds[] = #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 @@ -296,6 +341,10 @@ tbaudrate(char *rate) ++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; @@ -795,7 +844,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) {