This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.1'.
[unix-history] / bin / stty / cchar.c
index 7fd8e26..b8e6206 100644 (file)
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)cchar.c   5.4 (Berkeley) 6/10/91";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
-#include <sys/unistd.h>
+#include <machine/limits.h>
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
@@ -86,7 +86,8 @@ csearch(argvp, ip)
        extern char *usage;
        register struct cchar *cp;
        struct cchar tmp;
        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;
        static int c_cchar __P((const void *, const void *));
                
        name = **argvp;
@@ -104,9 +105,23 @@ csearch(argvp, ip)
                err("option requires an argument -- %s\n%s", name, usage);
 
 #define CHK(s)  (*arg == s[0] && !strcmp(arg, s))
                err("option requires an argument -- %s\n%s", name, usage);
 
 #define CHK(s)  (*arg == s[0] && !strcmp(arg, s))
-       if (CHK("undef") || CHK("<undef>")) 
+       if (CHK("undef") || CHK("<undef>"))
                ip->t.c_cc[cp->sub] = _POSIX_VDISABLE;
                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
                ip->t.c_cc[cp->sub] = (arg[1] == '?') ? 0177 :
                    (arg[1] == '-') ? _POSIX_VDISABLE : arg[1] & 037;
        else