From admin@mail.jmrodgers.com  Tue Feb 24 12:56:12 1998
Received: from mail.jmrodgers.com ([205.247.224.9])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA08779
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 24 Feb 1998 12:56:04 -0800 (PST)
          (envelope-from admin@mail.jmrodgers.com)
Received: (from admin@localhost)
	by mail.jmrodgers.com (8.8.8/8.8.7) id PAA01663;
	Tue, 24 Feb 1998 15:55:56 -0500 (EST)
	(envelope-from admin)
Message-Id: <199802242055.PAA01663@mail.jmrodgers.com>
Date: Tue, 24 Feb 1998 15:55:56 -0500 (EST)
From: meuston@jmrodgers.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: Make more(1) use LINES= and COLUMNS= environment variables.
X-Send-Pr-Version: 3.2

>Number:         5838
>Category:       bin
>Synopsis:       Make more(1) use LINES= and COLUMNS= environment variables.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 24 13:00:01 PST 1998
>Closed-Date:    Fri Mar 13 10:40:22 PST 1998
>Last-Modified:  Fri Mar 13 10:42:35 PST 1998
>Originator:     Max Euston
>Release:        FreeBSD 2.2.5-STABLE i386
>Organization:
>Environment:

FreeBSD mail.jmrodgers.com 2.2.5-STABLE FreeBSD 2.2.5-STABLE #0: Tue Feb 24 08:33:10 EST 1998     root@:/var/src/sys/compile/GATEWAY  i386

>Description:

3 problems:

	- more(1) does not work with arbitrary screen sizes (like in a
	  telnet session from Win-95) and has no way to specify the screen
	  size without generating a new terminfo definition.

	- the '-#' option was meant to do this, but has not worked as far
	  back as I can check in the revision history.  (as per the
	  discussions on "hackers", I have removed this option).

	- when displaying h)elp, more(1) does not pause before redrawing
	  the screen (unless you have MORE=-e in your environment).

>How-To-Repeat:

	Run more(1) from a telnet session with a non-standard screen size.

>Fix:

	(This is my first PR, feel free to suggest improvments/corrections).

	Should apply to RELENG_2_2 and HEAD?

diff -ru /usr/src/usr.bin/more/help.c /usr/local/src/usr.bin/more/help.c
--- /usr/src/usr.bin/more/help.c	Fri May 27 08:30:46 1994
+++ /usr/local/src/usr.bin/more/help.c	Wed Feb 18 10:27:41 1998
@@ -40,10 +40,12 @@
 #include <less.h>
 #include "pathnames.h"
 
+extern int top_scroll;
+
 help()
 {
 	char cmd[MAXPATHLEN + 20];
 
-	(void)sprintf(cmd, "-more %s", _PATH_HELPFILE);
+	(void)sprintf(cmd, "-more -e%c %s", top_scroll ? 'c' : ' ', _PATH_HELPFILE);
 	lsystem(cmd);
 }
diff -ru /usr/src/usr.bin/more/more.1 /usr/local/src/usr.bin/more/more.1
--- /usr/src/usr.bin/more/more.1	Wed Jul 30 02:43:57 1997
+++ /usr/local/src/usr.bin/more/more.1	Tue Feb 24 14:41:27 1998
@@ -40,11 +40,10 @@
 .Nd file perusal filter for crt viewing
 .Sh SYNOPSIS
 .Nm
-.Op Fl ceinus
+.Op Fl ceinsu
 .Op Fl t Ar tag
 .Op Fl x Ar tabs
 .Op Fl / Ar pattern
-.Op Fl #
 .Op Ar
 .Sh DESCRIPTION
 .Nm More
@@ -278,8 +277,14 @@
 .It Ev MORE
 This variable may be set with favored options to
 .Nm more .
+.It Ev COLUMNS
+The number of columns on the screen.  This value overrides any system
+or terminal specific values.
 .It Ev EDITOR
 Specify default editor.
+.It Ev LINES
+The number of rows on the screen.  This value overrides any system
+or terminal specific values.
 .It Ev SHELL
 Current shell in use (normally set by the shell at login time).
 .It Ev TERM
diff -ru /usr/src/usr.bin/more/option.c /usr/local/src/usr.bin/more/option.c
--- /usr/src/usr.bin/more/option.c	Mon Sep 15 05:20:52 1997
+++ /usr/local/src/usr.bin/more/option.c	Tue Feb 24 14:45:27 1998
@@ -54,7 +54,6 @@
 int tagoption;
 
 char *firstsearch;
-extern int sc_height;
 
 static void usage __P((void));
 
@@ -75,23 +74,8 @@
 			(*a)[0] = '-';
 
 	optind = 1;		/* called twice, re-init getopt. */
-	while ((ch = getopt(argc, argv, "0123456789/:ceinst:ux:f")) != -1)
+	while ((ch = getopt(argc, argv, "/:ceinst:ux:f")) != -1)
 		switch((char)ch) {
-		case '0': case '1': case '2': case '3': case '4':
-		case '5': case '6': case '7': case '8': case '9':
-			/*
-			 * kludge: more was originally designed to take
-			 * a number after a dash.
-			 */
-			if (!sc_window_set) {
-				p = argv[optind - 1];
-				if (p[0] == '-' && p[1] == ch && !p[2])
-					sc_height = atoi(++p);
-				else
-					sc_height = atoi(argv[optind] + 1);
-				sc_window_set = 1;
-			}
-			break;
 		case '/':
 			firstsearch = optarg;
 			break;
@@ -135,6 +119,6 @@
 usage()
 {
 	fprintf(stderr,
-	"usage: more [-ceinus] [-t tag] [-x tabs] [-/ pattern] [-#] [file ...]\n");
+	"usage: more [-ceinsu] [-t tag] [-x tabs] [-/ pattern] [file ...]\n");
 	exit(1);
 }
diff -ru /usr/src/usr.bin/more/screen.c /usr/local/src/usr.bin/more/screen.c
--- /usr/src/usr.bin/more/screen.c	Sat Aug  5 17:25:28 1995
+++ /usr/local/src/usr.bin/more/screen.c	Mon Feb 23 16:54:19 1998
@@ -239,6 +239,7 @@
 	char termbuf[2048];
 	char *sp;
 	char *term;
+	char *estr;
 	int hard;
 #ifdef TIOCGWINSZ
 	struct winsize w;
@@ -265,14 +266,22 @@
 #ifdef TIOCGWINSZ
 	if (ioctl(2, TIOCGWINSZ, &w) == 0 && w.ws_row > 0)
 		sc_height = w.ws_row;
+	else
 #else
 #ifdef WIOCGETD
 	if (ioctl(2, WIOCGETD, &w) == 0 && w.uw_height > 0)
 		sc_height = w.uw_height/w.uw_vs;
+	else
 #endif
 #endif
-	else
 		sc_height = tgetnum("li");
+
+	/*
+	 * Allow the user to override the screen height
+	 */
+ 	if ((estr = getenv("LINES")) != NULL)
+ 		sc_height = atoi(estr);
+
 	hard = (sc_height < 0 || tgetflag("hc"));
 	if (hard) {
 		/* Oh no, this is a hardcopy terminal. */
@@ -290,6 +299,13 @@
 #endif
 #endif
  		sc_width = tgetnum("co");
+
+	/*
+	 * Allow the user to override the screen width
+	 */
+ 	if ((estr = getenv("COLUMNS")) != NULL)
+ 		sc_width = atoi(estr);
+
  	if (sc_width < 0)
   		sc_width = 80;
 

--------------- end
>Release-Note:
>Audit-Trail:

From: Bill Fenner <fenner@parc.xerox.com>
To: meuston@jmrodgers.com
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/5838: Make more(1) use LINES= and COLUMNS= environment variables. 
Date: Tue, 24 Feb 1998 14:29:58 PST

 meuston@jmrodgers.com wrote:
 >	- more(1) does not work with arbitrary screen sizes (like in a
 >	  telnet session from Win-95) and has no way to specify the screen
 >	  size without generating a new terminfo definition.
 
 Have you tried "stty cols X rows Y"?
 
   Bill

From: Max Euston <meuston@jmrodgers.com>
To: "'Bill Fenner'" <fenner@parc.xerox.com>
Cc: "FreeBSD-gnats-submit@freebsd.org" <FreeBSD-gnats-submit@freebsd.org>
Subject: RE: bin/5838: Make more(1) use LINES= and COLUMNS= environment variables. 
Date: Wed, 25 Feb 1998 09:20:28 -0500

 On Tuesday, February 24, 1998 5:30 PM, Bill Fenner 
 [SMTP:fenner@parc.xerox.com] wrote:
 > meuston@jmrodgers.com wrote:
 > >	- more(1) does not work with arbitrary screen sizes (like in a
 > >	  telnet session from Win-95) and has no way to specify the screen
 > >	  size without generating a new terminfo definition.
 >
 > Have you tried "stty cols X rows Y"?
 >
 >   Bill
 >
 Oh great! :-( another useless change - I wonder why it wasn't caught in the 
 discussion on "hackers"? :-)  I have never run into that option of stty.
 
 Since the other part of the change is still good ('help' does not pause 
 after displaying it's screen), would you think that it is better to retract 
 and resubmit this PR with the LINES and COLUMNS changes removed, or just 
 leave them in as another (redundant) way of doing the same thing?
 
 (Feeling a little sheepish).
 
 Max
 
 -----
 Max Euston <meuston@jmrodgers.com>
 Sysadm, Programmer, etc...
 
 
 

From: Bill Fenner <fenner@parc.xerox.com>
To: Max Euston <meuston@jmrodgers.com>
Cc: "'Bill Fenner'" <fenner@parc.xerox.com>,
        "FreeBSD-gnats-submit@freebsd.org" <FreeBSD-gnats-submit@freebsd.org>
Subject: Re: bin/5838: Make more(1) use LINES= and COLUMNS= environment variables. 
Date: Wed, 25 Feb 1998 08:15:37 PST

 You could just submit a revised diff without LINES and COLUMNS as a
 followup to this conversation; since it's cc'd to freebsd-gnats-submit,
 it'll be appended to the PR.
 
   Bill

From: Max Euston <meuston@jmrodgers.com>
To: "'Bill Fenner'" <fenner@parc.xerox.com>
Cc: "FreeBSD-gnats-submit@freebsd.org" <FreeBSD-gnats-submit@freebsd.org>
Subject: RE: bin/5838: Minor fixes to more(1) (was: Make more(1) use LINES= and COLUMNS= environment variables. )
Date: Wed, 25 Feb 1998 11:35:45 -0500

 On Wednesday, February 25, 1998 11:16 AM, Bill Fenner [SMTP:fenner@parc.xerox.com] wrote:
 > You could just submit a revised diff without LINES and COLUMNS as a
 > followup to this conversation; since it's cc'd to freebsd-gnats-submit,
 > it'll be appended to the PR.
 > 
 >   Bill
 > 
 
 (once I get cvs installed, these should be in the more standard format...)
 
 *****
 diff -u /usr/src/usr.bin/more/help.c /usr/local/src/usr.bin/more/help.c
 --- /usr/src/usr.bin/more/help.c	Fri May 27 08:30:46 1994
 +++ /usr/local/src/usr.bin/more/help.c	Wed Feb 18 10:27:41 1998
 @@ -40,10 +40,12 @@
  #include <less.h>
  #include "pathnames.h"
  
 +extern int top_scroll;
 +
  help()
  {
  	char cmd[MAXPATHLEN + 20];
  
 -	(void)sprintf(cmd, "-more %s", _PATH_HELPFILE);
 +	(void)sprintf(cmd, "-more -e%c %s", top_scroll ? 'c' : ' ', _PATH_HELPFILE);
  	lsystem(cmd);
  }
 *****
 diff -u /usr/src/usr.bin/more/more.1 /usr/local/src/usr.bin/more/more.1
 --- /usr/src/usr.bin/more/more.1	Wed Jul 30 02:43:57 1997
 +++ /usr/local/src/usr.bin/more/more.1	Wed Feb 25 11:28:20 1998
 @@ -40,11 +40,10 @@
  .Nd file perusal filter for crt viewing
  .Sh SYNOPSIS
  .Nm
 -.Op Fl ceinus
 +.Op Fl ceinsu
  .Op Fl t Ar tag
  .Op Fl x Ar tabs
  .Op Fl / Ar pattern
 -.Op Fl #
  .Op Ar
  .Sh DESCRIPTION
  .Nm More
 *****
 diff -u /usr/src/usr.bin/more/option.c /usr/local/src/usr.bin/more/option.c
 --- /usr/src/usr.bin/more/option.c	Mon Sep 15 05:20:52 1997
 +++ /usr/local/src/usr.bin/more/option.c	Tue Feb 24 14:45:27 1998
 @@ -54,7 +54,6 @@
  int tagoption;
  
  char *firstsearch;
 -extern int sc_height;
  
  static void usage __P((void));
  
 @@ -75,23 +74,8 @@
  			(*a)[0] = '-';
  
  	optind = 1;		/* called twice, re-init getopt. */
 -	while ((ch = getopt(argc, argv, "0123456789/:ceinst:ux:f")) != -1)
 +	while ((ch = getopt(argc, argv, "/:ceinst:ux:f")) != -1)
  		switch((char)ch) {
 -		case '0': case '1': case '2': case '3': case '4':
 -		case '5': case '6': case '7': case '8': case '9':
 -			/*
 -			 * kludge: more was originally designed to take
 -			 * a number after a dash.
 -			 */
 -			if (!sc_window_set) {
 -				p = argv[optind - 1];
 -				if (p[0] == '-' && p[1] == ch && !p[2])
 -					sc_height = atoi(++p);
 -				else
 -					sc_height = atoi(argv[optind] + 1);
 -				sc_window_set = 1;
 -			}
 -			break;
  		case '/':
  			firstsearch = optarg;
  			break;
 @@ -135,6 +119,6 @@
  usage()
  {
  	fprintf(stderr,
 -	"usage: more [-ceinus] [-t tag] [-x tabs] [-/ pattern] [-#] [file ...]\n");
 +	"usage: more [-ceinsu] [-t tag] [-x tabs] [-/ pattern] [file ...]\n");
  	exit(1);
  }
 *****
 diff -u /usr/src/usr.bin/more/screen.c /usr/local/src/usr.bin/more/screen.c
 --- /usr/src/usr.bin/more/screen.c	Sat Aug  5 17:25:28 1995
 +++ /usr/local/src/usr.bin/more/screen.c	Wed Feb 25 11:27:57 1998
 @@ -265,13 +265,14 @@
  #ifdef TIOCGWINSZ
  	if (ioctl(2, TIOCGWINSZ, &w) == 0 && w.ws_row > 0)
  		sc_height = w.ws_row;
 +	else
  #else
  #ifdef WIOCGETD
  	if (ioctl(2, WIOCGETD, &w) == 0 && w.uw_height > 0)
  		sc_height = w.uw_height/w.uw_vs;
 +	else
  #endif
  #endif
 -	else
  		sc_height = tgetnum("li");
  	hard = (sc_height < 0 || tgetflag("hc"));
  	if (hard) {
 *****
 
 -----
 Max Euston <meuston@jmrodgers.com>
 Sysadm, Programmer, etc...
 
State-Changed-From-To: open->closed 
State-Changed-By: hoek 
State-Changed-When: Fri Mar 13 10:40:22 PST 1998 
State-Changed-Why:  
Closed on request of submitter, who promises to resubmit a new and improved 
pr at some point in time.  We eagerly wait with bated breath, Max! 
>Unformatted:
