X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftset.c;h=8b96838e3fa04d83820d818c5d01803126db2b01;hp=029207678738564b26597c4b1c2a5a7f52212872;hb=e2e9c09c48b19b24979cafb2d4864f538b5ddd1c;hpb=96592d717179f99c8fe1c5a63fc4a26c24867288 diff --git a/progs/tset.c b/progs/tset.c index 02920767..8b96838e 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.107 2016/08/06 20:54:22 tom Exp $") +MODULE_ID("$Id: tset.c,v 1.112 2016/09/10 23:33:10 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; @@ -492,6 +541,8 @@ get_termcap_entry(int fd, char *userarg) #endif char *ttypath; + (void) fd; + if (userarg) { ttype = userarg; goto found;