date and time created 95/05/04 17:59:12 by christos
[unix-history] / usr / src / bin / stty / print.c
index 6e9acb5..51a0f46 100644 (file)
@@ -1,24 +1,26 @@
 /*-
 /*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1991, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
  */
 
 #ifndef lint
  *
  * %sccs.include.redist.c%
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)print.c    5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)print.c    8.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
+
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
+
 #include "stty.h"
 #include "extern.h"
 
 static void  binit __P((char *));
 static void  bput __P((char *));
 #include "stty.h"
 #include "extern.h"
 
 static void  binit __P((char *));
 static void  bput __P((char *));
-static char *ccval __P((int));
+static char *ccval __P((struct cchar *, int));
 
 void
 print(tp, wp, ldisc, fmt)
 
 void
 print(tp, wp, ldisc, fmt)
@@ -27,11 +29,10 @@ print(tp, wp, ldisc, fmt)
        int ldisc;
        enum FMT fmt;
 {
        int ldisc;
        enum FMT fmt;
 {
-       register struct cchar *p;
-       register long tmp;
-       register int cnt;
-       register u_char *cc;
-       int ispeed, ospeed;
+       struct cchar *p;
+       long tmp;
+       u_char *cc;
+       int cnt, ispeed, ospeed;
        char buf1[100], buf2[100];
 
        cnt = 0;
        char buf1[100], buf2[100];
 
        cnt = 0;
@@ -85,7 +86,6 @@ print(tp, wp, ldisc, fmt)
        put("-altwerase", ALTWERASE, 0);
        put("-noflsh", NOFLSH, 0);
        put("-tostop", TOSTOP, 0);
        put("-altwerase", ALTWERASE, 0);
        put("-noflsh", NOFLSH, 0);
        put("-tostop", TOSTOP, 0);
-       put("-mdmbuf", MDMBUF, 0);
        put("-flusho", FLUSHO, 0);
        put("-pendin", PENDIN, 0);
        put("-nokerninfo", NOKERNINFO, 0);
        put("-flusho", FLUSHO, 0);
        put("-pendin", PENDIN, 0);
        put("-nokerninfo", NOKERNINFO, 0);
@@ -139,6 +139,7 @@ print(tp, wp, ldisc, fmt)
        put("-clocal", CLOCAL, 0);
        put("-cstopb", CSTOPB, 0);
        put("-crtscts", CRTSCTS, 0);
        put("-clocal", CLOCAL, 0);
        put("-cstopb", CSTOPB, 0);
        put("-crtscts", CRTSCTS, 0);
+       put("-mdmbuf", MDMBUF, 0);
 
        /* special control characters */
        cc = tp->c_cc;
 
        /* special control characters */
        cc = tp->c_cc;
@@ -146,7 +147,7 @@ print(tp, wp, ldisc, fmt)
                binit("cchars");
                for (p = cchars1; p->name; ++p) {
                        (void)snprintf(buf1, sizeof(buf1), "%s = %s;",
                binit("cchars");
                for (p = cchars1; p->name; ++p) {
                        (void)snprintf(buf1, sizeof(buf1), "%s = %s;",
-                           p->name, ccval(cc[p->sub]));
+                           p->name, ccval(p, cc[p->sub]));
                        bput(buf1);
                }
                binit(NULL);
                        bput(buf1);
                }
                binit(NULL);
@@ -157,7 +158,7 @@ print(tp, wp, ldisc, fmt)
                                continue;
 #define        WD      "%-8s"
                        (void)sprintf(buf1 + cnt * 8, WD, p->name);
                                continue;
 #define        WD      "%-8s"
                        (void)sprintf(buf1 + cnt * 8, WD, p->name);
-                       (void)sprintf(buf2 + cnt * 8, WD, ccval(cc[p->sub]));
+                       (void)sprintf(buf2 + cnt * 8, WD, ccval(p, cc[p->sub]));
                        if (++cnt == LINELENGTH / 8) {
                                cnt = 0;
                                (void)printf("%s\n", buf1);
                        if (++cnt == LINELENGTH / 8) {
                                cnt = 0;
                                (void)printf("%s\n", buf1);
@@ -178,6 +179,7 @@ static void
 binit(lb)
        char *lb;
 {
 binit(lb)
        char *lb;
 {
+
        if (col) {
                (void)printf("\n");
                col = 0;
        if (col) {
                (void)printf("\n");
                col = 0;
@@ -189,6 +191,7 @@ static void
 bput(s)
        char *s;
 {
 bput(s)
        char *s;
 {
+
        if (col == 0) {
                col = printf("%s: %s", label, s);
                return;
        if (col == 0) {
                col = printf("%s: %s", label, s);
                return;
@@ -202,15 +205,20 @@ bput(s)
 }
 
 static char *
 }
 
 static char *
-ccval(c)
+ccval(p, c)
+       struct cchar *p;
        int c;
 {
        static char buf[5];
        char *bp;
 
        if (c == _POSIX_VDISABLE)
        int c;
 {
        static char buf[5];
        char *bp;
 
        if (c == _POSIX_VDISABLE)
-               return("<undef>");
+               return ("<undef>");
 
 
+       if (p->sub == VMIN || p->sub == VTIME) {
+               (void)snprintf(buf, sizeof(buf), "%d", c);
+               return (buf);
+       }
        bp = buf;
        if (c & 0200) {
                *bp++ = 'M';
        bp = buf;
        if (c & 0200) {
                *bp++ = 'M';
@@ -228,5 +236,5 @@ ccval(c)
        else
                *bp++ = c;
        *bp = '\0';
        else
                *bp++ = c;
        *bp = '\0';
-       return(buf);
+       return (buf);
 }
 }