diff options
Diffstat (limited to 'bin/stty/cchar.c')
| -rw-r--r-- | bin/stty/cchar.c | 22 | 
1 files changed, 19 insertions, 3 deletions
| diff --git a/bin/stty/cchar.c b/bin/stty/cchar.c index 458867c7ffc4..b8e6206cfa59 100644 --- a/bin/stty/cchar.c +++ b/bin/stty/cchar.c @@ -36,6 +36,7 @@ static char sccsid[] = "@(#)cchar.c	5.4 (Berkeley) 6/10/91";  #endif /* not lint */  #include <sys/types.h> +#include <machine/limits.h>  #include <stddef.h>  #include <stdlib.h>  #include <string.h> @@ -85,7 +86,8 @@ csearch(argvp, ip)  	extern char *usage;  	register struct cchar *cp;  	struct cchar tmp; -	char *arg, *name; +	long val; +	char *arg, *ep, *name;  	static int c_cchar __P((const void *, const void *));  	name = **argvp; @@ -102,10 +104,24 @@ csearch(argvp, ip)  	if (!arg)  		err("option requires an argument -- %s\n%s", name, usage); -#define CHK(s)  (*name == s[0] && !strcmp(name, s)) +#define CHK(s)  (*arg == s[0] && !strcmp(arg, s))  	if (CHK("undef") || CHK("<undef>"))  		ip->t.c_cc[cp->sub] = _POSIX_VDISABLE; -	else if (arg[0] == '^') +	else if (cp->sub == VMIN || cp->sub == VTIME) { +		val = strtol(arg, &ep, 10); +		if (val == _POSIX_VDISABLE) { +			warnx("value of %ld would disable the option -- %s", +			    val, name); +		} +		if (val > UCHAR_MAX) { +			warnx("maximum option value is %d -- %s", +			    UCHAR_MAX, name); +		} +		if (*ep != '\0') { +			warnx("option requires a numeric argument -- %s", name); +		} +		ip->t.c_cc[cp->sub] = val; +	} else if (arg[0] == '^')  		ip->t.c_cc[cp->sub] = (arg[1] == '?') ? 0177 :  		    (arg[1] == '-') ? _POSIX_VDISABLE : arg[1] & 037;  	else | 
