[BACK]Return to edit.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / less

Diff for /src/usr.bin/less/edit.c between version 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2003/04/13 18:21:21 version 1.1.1.3, 2011/09/16 17:47:04
Line 1 
Line 1 
 /*  /*
  * Copyright (C) 1984-2002  Mark Nudelman   * Copyright (C) 1984-2011  Mark Nudelman
  *   *
  * You may distribute under the terms of either the GNU General Public   * You may distribute under the terms of either the GNU General Public
  * License or the Less License, as specified in the README file.   * License or the Less License, as specified in the README file.
Line 10 
Line 10 
   
   
 #include "less.h"  #include "less.h"
   #if HAVE_STAT
   #include <sys/stat.h>
   #endif
   
 public int fd0 = 0;  public int fd0 = 0;
   
Line 36 
Line 39 
 extern char *namelogfile;  extern char *namelogfile;
 #endif  #endif
   
   #if HAVE_STAT_INO
   public dev_t curr_dev;
   public ino_t curr_ino;
   #endif
   
 char *curr_altfilename = NULL;  char *curr_altfilename = NULL;
 static void *curr_altpipe;  static void *curr_altpipe;
   
Line 178 
Line 186 
                 curr_altfilename = NULL;                  curr_altfilename = NULL;
         }          }
         curr_ifile = NULL_IFILE;          curr_ifile = NULL_IFILE;
   #if HAVE_STAT_INO
           curr_ino = curr_dev = 0;
   #endif
 }  }
   
 /*  /*
Line 322 
Line 333 
                 /*                  /*
                  * Re-open the current file.                   * Re-open the current file.
                  */                   */
                   if (was_curr_ifile == ifile)
                   {
                           /*
                            * Whoops.  The "current" ifile is the one we just deleted.
                            * Just give up.
                            */
                           quit(QUIT_ERROR);
                   }
                 reedit_ifile(was_curr_ifile);                  reedit_ifile(was_curr_ifile);
                 return (1);                  return (1);
         } else if ((f = open(qopen_filename, OPEN_READ)) < 0)          } else if ((f = open(qopen_filename, OPEN_READ)) < 0)
Line 352 
Line 371 
                         }                          }
                 }                  }
         }          }
         free(qopen_filename);  
   
         /*          /*
          * Get the new ifile.           * Get the new ifile.
Line 377 
Line 395 
                 if (namelogfile != NULL && is_tty)                  if (namelogfile != NULL && is_tty)
                         use_logfile(namelogfile);                          use_logfile(namelogfile);
 #endif  #endif
   #if HAVE_STAT_INO
                   /* Remember the i-number and device of the opened file. */
                   {
                           struct stat statbuf;
                           int r = stat(qopen_filename, &statbuf);
                           if (r == 0)
                           {
                                   curr_ino = statbuf.st_ino;
                                   curr_dev = statbuf.st_dev;
                           }
                   }
   #endif
                 if (every_first_cmd != NULL)                  if (every_first_cmd != NULL)
                         ungetsc(every_first_cmd);                          ungetsc(every_first_cmd);
         }          }
   
           free(qopen_filename);
         no_display = !any_display;          no_display = !any_display;
         flush();          flush();
         any_display = TRUE;          any_display = TRUE;
Line 498 
Line 529 
   
   
 /*  /*
  * Edit the next or previous file in the command line (ifile) list.   * Edit the n-th next or previous file in the command line (ifile) list.
  */   */
         static int          static int
 edit_istep(h, n, dir)  edit_istep(h, n, dir)
Line 547 
Line 578 
         IFILE h;          IFILE h;
         int n;          int n;
 {  {
         return (edit_istep(h, n, 1));          return (edit_istep(h, n, +1));
 }  }
   
         public int          public int
 edit_next(n)  edit_next(n)
         int n;          int n;
 {  {
         return edit_istep(curr_ifile, n, 1);          return edit_istep(curr_ifile, n, +1);
 }  }
   
         static int          static int
Line 649 
Line 680 
         quit(QUIT_ERROR);          quit(QUIT_ERROR);
 }  }
   
           public void
   reopen_curr_ifile()
   {
           IFILE save_ifile = save_curr_ifile();
           close_file();
           reedit_ifile(save_ifile);
   }
   
 /*  /*
  * Edit standard input.   * Edit standard input.
  */   */
Line 739 
Line 778 
                  * Append: open the file and seek to the end.                   * Append: open the file and seek to the end.
                  */                   */
                 logfile = open(filename, OPEN_APPEND);                  logfile = open(filename, OPEN_APPEND);
                 if (lseek(logfile, (off_t)0, 2) == BAD_LSEEK)                  if (lseek(logfile, (off_t)0, SEEK_END) == BAD_LSEEK)
                 {                  {
                         close(logfile);                          close(logfile);
                         logfile = -1;                          logfile = -1;

Legend:
Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3