let "crt" default to the screen height from TIOCGWINSZ
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Fri, 17 Jun 1988 10:23:08 +0000 (02:23 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Fri, 17 Jun 1988 10:23:08 +0000 (02:23 -0800)
SCCS-vsn: usr.bin/mail/glob.h 5.6
SCCS-vsn: usr.bin/mail/main.c 5.10
SCCS-vsn: usr.bin/mail/cmd1.c 5.7

usr/src/usr.bin/mail/cmd1.c
usr/src/usr.bin/mail/glob.h
usr/src/usr.bin/mail/main.c

index 6dcce07..6bec2eb 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #ifdef notdef
  */
 
 #ifdef notdef
-static char sccsid[] = "@(#)cmd1.c     5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmd1.c     5.7 (Berkeley) %G%";
 #endif /* notdef */
 
 #include "rcv.h"
 #endif /* notdef */
 
 #include "rcv.h"
@@ -319,7 +319,7 @@ type1(msgvec, doign, page)
                        for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++)
                                nlines += message[*ip - 1].m_lines;
                }
                        for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++)
                                nlines += message[*ip - 1].m_lines;
                }
-               if (page || nlines > atoi(cp)) {
+               if (page || nlines > (*cp ? atoi(cp) : realscreenheight)) {
                        cp = value("PAGER");
                        if (cp == NULL || *cp == '\0')
                                cp = MORE;
                        cp = value("PAGER");
                        if (cp == NULL || *cp == '\0')
                                cp = MORE;
index 38275e9..59bd217 100644 (file)
@@ -9,7 +9,7 @@
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
- *     @(#)glob.h      5.5 (Berkeley) %G%
+ *     @(#)glob.h      5.6 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -42,7 +42,6 @@ char  *editfile;                      /* Name of file being edited */
 char   *sflag;                         /* Subject given from non tty */
 int    outtty;                         /* True if standard output a tty */
 int    intty;                          /* True if standard input a tty */
 char   *sflag;                         /* Subject given from non tty */
 int    outtty;                         /* True if standard output a tty */
 int    intty;                          /* True if standard input a tty */
-int    baud;                           /* Output baud rate */
 char   mbox[PATHSIZE];                 /* Name of mailbox file */
 char   mailname[PATHSIZE];             /* Name of system mailbox */
 int    uid;                            /* The invoker's user id */
 char   mbox[PATHSIZE];                 /* Name of mailbox file */
 char   mailname[PATHSIZE];             /* Name of system mailbox */
 int    uid;                            /* The invoker's user id */
@@ -70,7 +69,9 @@ char  **localnames;                   /* List of aliases for our local host */
 int    debug;                          /* Debug flag set */
 int    rmail;                          /* Being called as rmail */
 int    screenwidth;                    /* Screen width, or best guess */
 int    debug;                          /* Debug flag set */
 int    rmail;                          /* Being called as rmail */
 int    screenwidth;                    /* Screen width, or best guess */
-int    screenheight;                   /* Screen height, or best guess */
+int    screenheight;                   /* Screen height, or best guess,
+                                          for "header" command */
+int    realscreenheight;               /* the real screen height */
 
 #include <setjmp.h>
 
 
 #include <setjmp.h>
 
index f4b940b..7cf6009 100644 (file)
@@ -17,7 +17,7 @@ char copyright[] =
 #endif /* notdef */
 
 #ifdef notdef
 #endif /* notdef */
 
 #ifdef notdef
-static char sccsid[] = "@(#)main.c     5.9 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.10 (Berkeley) %G%";
 #endif /* notdef */
 
 #include "rcv.h"
 #endif /* notdef */
 
 #include "rcv.h"
@@ -49,7 +49,6 @@ main(argc, argv)
        register int i;
        struct name *to, *cc, *bcc, *smopts;
        int  mustsend, hdrstop(), (*prevint)(), f;
        register int i;
        struct name *to, *cc, *bcc, *smopts;
        int  mustsend, hdrstop(), (*prevint)(), f;
-       struct sgttyb tbuf;
        extern int getopt(), optind, opterr;
        extern char *optarg;
 
        extern int getopt(), optind, opterr;
        extern char *optarg;
 
@@ -62,11 +61,6 @@ main(argc, argv)
        mypid = getpid();
        intty = isatty(0);
        outtty = isatty(1);
        mypid = getpid();
        intty = isatty(0);
        outtty = isatty(1);
-       if (outtty) {
-               gtty(1, &tbuf);
-               baud = tbuf.sg_ospeed;
-       } else
-               baud = B9600;
        image = -1;
 
        /*
        image = -1;
 
        /*
@@ -304,7 +298,7 @@ hdrstop()
 }
 
 /*
 }
 
 /*
- * Compute what the screen size should be.
+ * Compute what the screen size for printing headers should be.
  * We use the following algorithm for the height:
  *     If baud rate < 1200, use  9
  *     If baud rate = 1200, use 14
  * We use the following algorithm for the height:
  *     If baud rate < 1200, use  9
  *     If baud rate = 1200, use 14
@@ -313,26 +307,27 @@ hdrstop()
  */
 setscreensize()
 {
  */
 setscreensize()
 {
+       struct sgttyb tbuf;
 #ifdef TIOCGWINSZ
        struct winsize ws;
 
        if (ioctl(fileno(stdout), TIOCGWINSZ, (char *) &ws) < 0)
 #ifdef TIOCGWINSZ
        struct winsize ws;
 
        if (ioctl(fileno(stdout), TIOCGWINSZ, (char *) &ws) < 0)
-               ws.ws_col = ws.ws_row = 0;
 #endif
 #endif
-       if (baud < B1200)
+               ws.ws_col = ws.ws_row = 0;
+       if (outtty)
+               gtty(1, &tbuf);
+       else
+               tbuf.sg_ospeed = B9600;
+       if (tbuf.sg_ospeed < B1200)
                screenheight = 9;
                screenheight = 9;
-       else if (baud == B1200)
+       else if (tbuf.sg_ospeed == B1200)
                screenheight = 14;
                screenheight = 14;
-#ifdef TIOCGWINSZ
        else if (ws.ws_row != 0)
                screenheight = ws.ws_row;
        else if (ws.ws_row != 0)
                screenheight = ws.ws_row;
-#endif
        else
                screenheight = 24;
        else
                screenheight = 24;
-#ifdef TIOCGWINSZ
-       if (ws.ws_col != 0)
-               screenwidth = ws.ws_col;
-       else
-#endif
+       if ((realscreenheight = ws.ws_row) == 0)
+               realscreenheight = 24;
+       if ((screenwidth = ws.ws_col) == 0)
                screenwidth = 80;
 }
                screenwidth = 80;
 }