[7587] in Athena Bugs
fixes to /usr/ucb/more
daemon@ATHENA.MIT.EDU (Calvin Clark)
Wed May 22 20:00:08 1991
Date: Wed, 22 May 91 19:59:37 -0400
From: Calvin Clark <ckclark@ATHENA.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
Reply-To: ckclark@mit.edu
Cc: kevles@ATHENA.MIT.EDU, gamadrid@ATHENA.MIT.EDU, reaburn@ATHENA.MIT.EDU,
I made a couple simple fixes to `more' which should solve the problems
each of you reported in bugs. Included in this patch is Ezra's changes
which fix the problems that occur when running `more' on an empty file.
This was an old fix that one got one audit in on it, but I have looked
at it and Lo! I saw that it was Good.
It turns out that the problems reported by Beth and by George are the
same, and are due to `more' not cleaning up after itself on exit. The
problem is only seen in absence of the `-c' flag and do not occur if the
environment variable MORE is set to the Athena default (`setenv MORE
-csd' is in the global `cshrc' file.)
I fixed the problem with trying to do a :n when there are no input files
(i.e., the input is from stdin) by disabling it in that situation. It
now does the same thing that 0:n would do in more with multiple file
arguments---nothing. (Before it would either exit or print garbage and
exit. That is *wrong*.)
Actually, I didn't fix Ken's bug, (`-c' ignored if term is ansi). It
seems that in order to have clreol capability in more, your terminal
characteristics must include `ho' (Home) `ce' (eraseln) *and* `cd'
(EodClr). Since ansi lacks the last capability, the `-c' option is
disabled. The program is more pessimistic about the terminal type than
the man page seems to indicate, but that's another problem altogether.
I'll let others debate what `ansi' should and should not be able to do.
I'm going to push for these changes to be included the next release, so
I may ask for an audit from a couple of you to make it kosher.
Jay: Since you already audited Ezra's stuff, a simple "yes, this looks
reasonable" will suffice from you. Unless, of course, it's not
reasonable :-)
Enjoy!
*** more.c.orig Wed May 22 18:47:32 1991
--- more.c Wed May 22 18:51:07 1991
***************
*** 323,330 ****
fnum++;
firstf = 0;
}
! reset_tty ();
! exit(0);
}
argscan(s)
--- 323,329 ----
fnum++;
firstf = 0;
}
! end_it();
}
argscan(s)
***************
*** 403,408 ****
--- 402,411 ----
perror(fs);
return (NULL);
}
+ if ((file_size = stbuf.st_size) == 0) {
+ file_size = ULONG_MAX;
+ return(f);
+ }
c = Getc(f);
k = *(unsigned int *)((char *)f->_ptr - 1);
/* Try to see whether it is an ASCII file */
***************
*** 435,442 ****
*clearfirst = 0;
Ungetc (c, f);
}
- if ((file_size = stbuf.st_size) == 0)
- file_size = ULONG_MAX;
return (f);
}
--- 438,443 ----
***************
*** 1546,1552 ****
skipf (nskip)
register int nskip;
{
! if (nskip == 0) return;
if (nskip > 0) {
if (fnum + nskip > nfiles - 1)
nskip = nfiles - fnum - 1;
--- 1547,1553 ----
skipf (nskip)
register int nskip;
{
! if (nskip == 0 || nfiles == 0) return;
if (nskip > 0) {
if (fnum + nskip > nfiles - 1)
nskip = nfiles - fnum - 1;