[comp.bugs.4bsd] 4.[23]BSD more MORE variable flakiness

dce@mips.UUCP (09/01/87)

Index:	usr.ucb/more/more.c 4.3BSD Fix

Description:
	Line specification in MORE variable is ignored if command-line
	arguments are given. This was also broken in 4.2BSD.

Repeat-By:
	Set your MORE variable to "10c". Execute the commands

		more file
		more -s file

	where "file" has more than 10 lines of text in it.
	The first invocation will act like

		more -10c file

	The second acts like

		more -sc file

	instead of like

		more -10sc file

Fix:

*** more.c.old
--- more.c
***************
*** 262,275 ****
  argscan(s)
  char *s;
  {
! 	for (dlines = 0; *s != '\0'; s++)
! 	{
! 		switch (*s)
! 		{
  		  case '0': case '1': case '2':
  		  case '3': case '4': case '5':
  		  case '6': case '7': case '8':
  		  case '9':
  			dlines = dlines*10 + *s - '0';
  			break;
  		  case 'd':
--- 262,279 ----
  argscan(s)
  char *s;
  {
! 	int seen_num = 0;
! 
! 	while (*s != '\0') {
! 		switch (*s) {
  		  case '0': case '1': case '2':
  		  case '3': case '4': case '5':
  		  case '6': case '7': case '8':
  		  case '9':
+ 			if (!seen_num) {
+ 				dlines = 0;
+ 				seen_num = 1;
+ 			}
  			dlines = dlines*10 + *s - '0';
  			break;
  		  case 'd':
***************
*** 294,299 ****
--- 298,304 ----
  			ul_opt = 0;
  			break;
  		}
+ 		s++;
  	}
  }
  
-- 
David Elliott		{decvax,ucbvax,ihnp4}!decwrl!mips!dce