From 252f47a817aa489cf1de6645d8561144053c76d3 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Fri, 4 Aug 1995 06:44:54 +0000 Subject: [PATCH] Make tset works with non-fixed termios speeds too. Eliminate ospeed switch using new _set_ospeed function --- usr.bin/tset/extern.h | 12 ++---------- usr.bin/tset/map.c | 28 +++++----------------------- usr.bin/tset/tset.c | 29 +---------------------------- 3 files changed, 8 insertions(+), 61 deletions(-) diff --git a/usr.bin/tset/extern.h b/usr.bin/tset/extern.h index 0465a66aa04d..29acface3c37 100644 --- a/usr.bin/tset/extern.h +++ b/usr.bin/tset/extern.h @@ -33,15 +33,7 @@ * @(#)extern.h 8.1 (Berkeley) 6/9/93 */ -/* This should be in instead. */ -extern char PC; -extern short ospeed; -int tgetent __P((char *, char *)); -int tgetflag __P((char *)); -int tgetnum __P((char *)); -char *tgetstr __P((char *, char **)); -char *tgoto __P((char *, int, int)); -int tputs __P((char *, int, void (*) __P((int)))); +#include extern struct termios mode, oldmode; extern int columns, isreset, lines; @@ -52,7 +44,7 @@ void cat __P((char *)); void err __P((const char *, ...)); char *get_termcap_entry __P((char *, char **)); char *mapped __P((char *)); -void outc __P((int)); +int outc __P((int)); void reset_mode __P((void)); void set_control_chars __P((void)); void set_conversions __P((int)); diff --git a/usr.bin/tset/map.c b/usr.bin/tset/map.c index b20f43d3808f..2e71d2c502b4 100644 --- a/usr.bin/tset/map.c +++ b/usr.bin/tset/map.c @@ -225,30 +225,9 @@ typedef struct speeds { SPEEDS speeds[] = { "0", B0, - "50", B50, - "75", B75, - "110", B110, - "134", B134, "134.5", B134, - "150", B150, - "200", B200, - "300", B300, - "600", B600, - "1200", B1200, - "1800", B1800, - "2400", B2400, - "4800", B4800, - "9600", B9600, - "19200", B19200, - "38400", B38400, "exta", B19200, "extb", B38400, -#ifdef B57600 - "57600", B57600, -#endif -#ifdef B115200 - "115200", B115200, -#endif NULL }; @@ -257,6 +236,7 @@ baudrate(rate) char *rate; { SPEEDS *sp; + speed_t speed; /* The baudrate number can be preceded by a 'B', which is ignored. */ if (*rate == 'B') @@ -265,6 +245,8 @@ baudrate(rate) for (sp = speeds; sp->string; ++sp) if (!strcasecmp(rate, sp->string)) return (sp->speed); - err("unknown baud rate %s", rate); - /* NOTREACHED */ + speed = atol(rate); + if (speed == 0) + err("unknown baud rate %s", rate); + return speed; } diff --git a/usr.bin/tset/tset.c b/usr.bin/tset/tset.c index 74e12f32d904..0e09afcf0d20 100644 --- a/usr.bin/tset/tset.c +++ b/usr.bin/tset/tset.c @@ -81,34 +81,7 @@ main(argc, argv) oldmode = mode; Ospeed = cfgetospeed(&mode); - switch(Ospeed) { - case B0: ospeed = 0; break; - case B50: ospeed = 1; break; - case B75: ospeed = 2; break; - case B110: ospeed = 3; break; - case B134: ospeed = 4; break; - case B150: ospeed = 5; break; - case B200: ospeed = 6; break; - case B300: ospeed = 7; break; - case B600: ospeed = 8; break; - case B1200: ospeed = 9; break; - case B1800: ospeed = 10; break; - case B2400: ospeed = 11; break; - case B4800: ospeed = 12; break; - case B9600: ospeed = 13; break; -#ifdef EXTA - case EXTA: ospeed = 14; break; -#endif -#ifdef EXTB - case EXTB: ospeed = 15; break; -#endif -#ifdef B57600 - case B57600: ospeed = 16; break; -#endif -#ifdef B115200 - case B115200: ospeed = 17; break; -#endif - } + _set_ospeed(Ospeed); if (p = strrchr(*argv, '/')) ++p;