Bill added more buffers, and I put in sccs.
[unix-history] / usr / src / usr.bin / ex / ex3.7recover / ex3.7recover.c
index 17660b4..e12d722 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/* Copyright (c) 1980 Regents of the University of California */
+static char *sccsid = "@(#)ex3.7recover.c      4.2 %G%";
 #include "ex.h"
 #include "ex_temp.h"
 #include "ex_tty.h"
 #include "ex.h"
 #include "ex_temp.h"
 #include "ex_tty.h"
@@ -175,8 +176,13 @@ error(str, inf)
 {
 
        fprintf(stderr, str, inf);
 {
 
        fprintf(stderr, str, inf);
+#ifndef USG3TTY
        gtty(2, &tty);
        if ((tty.sg_flags & RAW) == 0)
        gtty(2, &tty);
        if ((tty.sg_flags & RAW) == 0)
+#else
+       ioctl(2, TCGETA, &tty);
+       if (tty.c_lflag & ICANON)
+#endif
                fprintf(stderr, "\n");
        exit(1);
 }
                fprintf(stderr, "\n");
        exit(1);
 }
@@ -488,7 +494,7 @@ nope:
         * puts a word LOST in the header block, so that lost lines
         * can be made to point at it.
         */
         * puts a word LOST in the header block, so that lost lines
         * can be made to point at it.
         */
-       ignorl(lseek(tfile, 504l, 0));
+       ignorl(lseek(tfile, (long)(BUFSIZ*HBLKS-8), 0));
        ignore(write(tfile, "LOST", 5));
        return (1);
 }
        ignore(write(tfile, "LOST", 5));
        return (1);
 }
@@ -522,7 +528,7 @@ scrapbad()
 
        ignore(fstat(tfile, &stbuf));
        size = stbuf.st_size;
 
        ignore(fstat(tfile, &stbuf));
        size = stbuf.st_size;
-       maxt = (size >> SHFT) | 7;
+       maxt = (size >> SHFT) | (BNDRY-1);
        bno = (maxt >> OFFBTS) & BLKMSK;
 #ifdef DEBUG
        fprintf(stderr, "size %ld, maxt %o, bno %d\n", size, maxt, bno);
        bno = (maxt >> OFFBTS) & BLKMSK;
 #ifdef DEBUG
        fprintf(stderr, "size %ld, maxt %o, bno %d\n", size, maxt, bno);
@@ -564,7 +570,7 @@ null:
 #endif
                        if (was == 0)
                                was = ip - zero;
 #endif
                        if (was == 0)
                                was = ip - zero;
-                       *ip = 504 >> SHFT;
+                       *ip = ((HBLKS*BUFSIZ)-8) >> SHFT;
                } else if (was) {
                        if (bad == 0)
                                fprintf(stderr, " [Lost line(s):");
                } else if (was) {
                        if (bad == 0)
                                fprintf(stderr, " [Lost line(s):");
@@ -738,7 +744,7 @@ blkio(b, buf, iofcn)
 {
 
        lseek(tfile, (long) (unsigned) b * BUFSIZ, 0);
 {
 
        lseek(tfile, (long) (unsigned) b * BUFSIZ, 0);
-       if ((*iofcn)(tfile, buf, BUFSIZ) != 512)
+       if ((*iofcn)(tfile, buf, BUFSIZ) != BUFSIZ)
                syserror();
 }
 
                syserror();
 }