rip out LOGFILE option
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 22 Jul 1988 10:21:28 +0000 (02:21 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 22 Jul 1988 10:21:28 +0000 (02:21 -0800)
SCCS-vsn: usr.bin/more/ch.c 5.3
SCCS-vsn: usr.bin/more/main.c 5.5
SCCS-vsn: usr.bin/more/option.c 5.3

usr/src/usr.bin/more/ch.c
usr/src/usr.bin/more/main.c
usr/src/usr.bin/more/option.c

index 9eef674..e2b44e2 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)ch.c       5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)ch.c       5.3 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -63,9 +63,6 @@ extern int ispipe;
 extern int autobuf;
 extern int cbufs;
 extern int sigs;
 extern int autobuf;
 extern int cbufs;
 extern int sigs;
-#if LOGFILE
-extern int logfile;
-#endif
 
 /*
  * Current position in file.
 
 /*
  * Current position in file.
@@ -176,14 +173,6 @@ fch_get()
        if (ispipe)
                last_piped_pos += n;
 
        if (ispipe)
                last_piped_pos += n;
 
-#if LOGFILE
-       /*
-        * If we have a log file, write the new data to it.
-        */
-       if (logfile >= 0 && n > 0)
-               write(logfile, &bp->data[bp->datasize], n);
-#endif
-
        bp->datasize += n;
 
        /*
        bp->datasize += n;
 
        /*
@@ -235,58 +224,6 @@ fch_get()
        return (bp->data[ch_offset]);
 }
 
        return (bp->data[ch_offset]);
 }
 
-#if LOGFILE
-/*
- * Close the logfile.
- * If we haven't read all of standard input into it, do that now.
- */
-       public void
-end_logfile()
-{
-       static int tried = 0;
-
-       if (logfile < 0)
-               return;
-       if (!tried && ch_fsize == NULL_POSITION)
-       {
-               tried = 1;
-               ierror("finishing logfile");
-               while (ch_forw_get() != EOI)
-                       if (sigs)
-                               break;
-       }
-       close(logfile);
-       logfile = -1;
-}
-
-/*
- * Start a log file AFTER less has already been running.
- * Invoked from the - command; see toggle_option().
- * Write all the existing buffered data to the log file.
- */
-       public void
-sync_logfile()
-{
-       register struct buf *bp;
-       register int n;
-       long block;
-       long last_block;
-
-       last_block = (last_piped_pos + BUFSIZ - 1) / BUFSIZ;
-       for (block = 0;  block <= last_block;  block++)
-               for (bp = buf_head;  bp != END_OF_CHAIN;  bp = bp->next)
-                       if (bp->block == block)
-                       {
-                               n = bp->datasize;
-                               if (bp->data[n-1] == EOI)
-                                       n--;
-                               write(logfile, bp->data, n);
-                               break;
-                       }
-}
-
-#endif
-
 /*
  * Determine if a specific block is currently in one of the buffers.
  */
 /*
  * Determine if a specific block is currently in one of the buffers.
  */
index 29105e7..706c96f 100644 (file)
@@ -27,7 +27,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -57,12 +57,6 @@ extern int   quit_at_eof;
 extern int     cbufs;
 extern int     errmsgs;
 
 extern int     cbufs;
 extern int     errmsgs;
 
-#if LOGFILE
-public int     logfile = -1;
-public int     force_logfile = 0;
-public char *  namelogfile = NULL;
-#endif
-
 public char *  editor;
 
 extern char *  tagfile;
 public char *  editor;
 
 extern char *  tagfile;
@@ -143,11 +137,6 @@ edit(filename)
                return;
        }
 
                return;
        }
 
-#if LOGFILE
-       if (f == 0 && namelogfile != NULL && is_tty)
-               use_logfile();
-#endif
-
        /*
         * We are now committed to using the new file.
         * Close the current input file and set up to use the new one.
        /*
         * We are now committed to using the new file.
         * Close the current input file and set up to use the new one.
@@ -237,74 +226,6 @@ cat_file()
        flush();
 }
 
        flush();
 }
 
-#if LOGFILE
-
-use_logfile()
-{
-       int exists;
-       int answer;
-       char message[100];
-
-       /*
-        * If he asked for a log file and we have opened standard input,
-        * create the log file.  
-        * We take care not to blindly overwrite an existing file.
-        */
-       end_logfile();
-
-       /*
-        * {{ We could use access() here. }}
-        */
-       exists = open(namelogfile, 0);
-       close(exists);
-       exists = (exists >= 0);
-
-       if (exists && !force_logfile)
-       {
-               static char w[] = "WARNING: log file exists: ";
-               strcpy(message, w);
-               strtcpy(message+sizeof(w)-1, namelogfile,
-                       sizeof(message)-sizeof(w));
-               error(message);
-               answer = 'X';   /* Ask the user what to do */
-       } else
-               answer = 'O';   /* Create the log file */
-
-loop:
-       switch (answer)
-       {
-       case 'O': case 'o':
-               logfile = creat(namelogfile, 0644);
-               break;
-       case 'A': case 'a':
-               logfile = open(namelogfile, 1);
-               if (lseek(logfile, (off_t)0, L_XTND) < 0)
-               {
-                       close(logfile);
-                       logfile = -1;
-               }
-               break;
-       case 'D': case 'd':
-               answer = 0;     /* Don't print an error message */
-               break;
-       case 'q':
-               quit();
-       default:
-               putstr("\n  Overwrite, Append, or Don't log? ");
-               answer = getchr();
-               putstr("\n");
-               flush();
-               goto loop;
-       }
-
-       if (logfile < 0 && answer != 0)
-       {
-               sprintf(message, "Cannot write to \"%s\"", 
-                       namelogfile);
-               error(message);
-       }
-}
-
 /*
  * Entry point.
  */
 /*
  * Entry point.
  */
@@ -463,9 +384,6 @@ quit()
         * reset the terminal modes, and exit.
         */
        quitting = 1;
         * reset the terminal modes, and exit.
         */
        quitting = 1;
-#if LOGFILE
-       end_logfile();
-#endif
        lower_left();
        clear_eol();
        deinit();
        lower_left();
        clear_eol();
        deinit();
index 1136ab8..6f9fc1b 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)option.c   5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)option.c   5.3 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -75,11 +75,6 @@ extern int sc_window;
 extern int ispipe;
 extern char *first_cmd;
 extern char *every_first_cmd;
 extern int ispipe;
 extern char *first_cmd;
 extern char *every_first_cmd;
-#if LOGFILE
-extern char *namelogfile;
-extern int force_logfile;
-extern int logfile;
-#endif
 extern char *tagfile;
 extern char *tagpattern;
 public int tagoption = 0;
 extern char *tagfile;
 extern char *tagpattern;
 public int tagoption = 0;
@@ -252,43 +247,6 @@ toggle_option(s, do_toggle)
                        (void) tagsearch();
                }
                return;
                        (void) tagsearch();
                }
                return;
-#if LOGFILE
-       case 'L':
-               /*
-                * Special case for -l and -L.
-                */
-               force_logfile = 1;
-               goto case_l;
-       case 'l':
-               force_logfile = 0;
-       case_l:
-               if (*s == '\0')
-               {
-                       if (logfile < 0)
-                               error("no log file");
-                       else
-                       {
-                               sprintf(message, "log file \"%s\"",
-                                       namelogfile);
-                               error(message);
-                       }
-                       return;
-               }
-               if (!ispipe)
-               {
-                       error("input is not a pipe");
-                       return;
-               }
-               if (logfile >= 0)
-               {
-                       error("log file is already in use");
-                       return;
-               }
-               namelogfile = save(s);
-               use_logfile();
-               sync_logfile();
-               return;
-#endif
        }
 
        msg = NULL;
        }
 
        msg = NULL;
@@ -389,10 +347,6 @@ single_char_option(c)
                return (0);
        if (c == 't')
                return (0);
                return (0);
        if (c == 't')
                return (0);
-#if LOGFILE
-       if (c == 'l' || c == 'L')
-               return (0);
-#endif
        for (o = option;  o->oletter != '\0';  o++)
                if (o->oletter == c)
                        return (o->otype & (BOOL|TRIPLE));
        for (o = option;  o->oletter != '\0';  o++)
                if (o->oletter == c)
                        return (o->otype & (BOOL|TRIPLE));
@@ -464,15 +418,6 @@ scan_option(s)
                first_cmd = s;
                s = optstring(s, c);
                goto next;
                first_cmd = s;
                s = optstring(s, c);
                goto next;
-#if LOGFILE
-       case 'L':
-               force_logfile = 1;
-               /* FALLTHRU */
-       case 'l':
-               namelogfile = s;
-               s = optstring(s, c);
-               goto next;
-#endif
        case 't':
        {
                char *p;
        case 't':
        {
                char *p;