[13232] in Athena Bugs
RSAIX 7.7: more: zero-length files + PATCH
daemon@ATHENA.MIT.EDU (Richard Basch)
Tue Feb 21 13:41:16 1995
Date: Tue, 21 Feb 1995 13:41:05 -0500
To: bugs@MIT.EDU, rel-eng@MIT.EDU
From: "Richard Basch" <basch@MIT.EDU>
Mike: If you are going to assign it to me, mark it release-wait.
More should not attempt to print anything for zero-length files. On the
RISC/6000, I see a garbage character. The following was done in an
emacs shell, although in a regular shell, I often see a y with an umlat.
<tardis!probe> {~}
39% more safe
<tardis!probe> {~}
40% ls -l safe
-rw-rw-r-- 1 probe mit 0 Feb 19 19:15 safe
Patch (TESTED):
--- /afs/dev/source/src/rsaix/more/more.c Fri Dec 13 04:58:01 1991
+++ more.c Tue Feb 21 13:38:36 1995
@@ -392,7 +392,7 @@
{
struct stat stbuf;
register FILE *f;
- char c;
+ int c;
unsigned int k;
int swapped = 0;
@@ -412,7 +412,11 @@
perror(fs);
return (NULL);
}
- c = Getc(f);
+ if ((c = Getc(f)) == EOF) {
+ fclose (f);
+ return (NULL);
+ }
+
k = *(unsigned int *)((char *)f->_ptr - 1);
/* Try to see whether it is an ASCII file */