[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.7 and 1.8

version 1.7, 2010/07/03 16:29:46 version 1.8, 2011/09/16 18:12:09
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;
   
   #if EXAMINE || TAB_COMPLETE_FILENAME
 /*  /*
  * Textlist functions deal with a list of words separated by spaces.   * Textlist functions deal with a list of words separated by spaces.
  * init_textlist sets up a textlist structure.   * init_textlist sets up a textlist structure.
Line 115 
Line 123 
         return (s);          return (s);
 }  }
   
 #ifndef SMALL_PROGRAM  
         public char *          public char *
 back_textlist(tlist, prev)  back_textlist(tlist, prev)
         struct textlist *tlist;          struct textlist *tlist;
Line 141 
Line 148 
                 s--;                  s--;
         return (s);          return (s);
 }  }
 #endif /* SMALL_PROGRAM */  #endif /* EXAMINE || TAB_COMPLETE_FILENAME */
   
 /*  /*
  * Close the current input file.   * Close the current input file.
Line 180 
Line 187 
                 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 239 
Line 249 
         {          {
                 chflags = ch_getflags();                  chflags = ch_getflags();
                 close_file();                  close_file();
   #if !SMALL
                   if ((chflags & CH_HELPFILE) && held_ifile(was_curr_ifile) <= 1)
                   {
                           /*
                            * Don't keep the help file in the ifile list.
                            */
                           del_ifile(was_curr_ifile);
                           was_curr_ifile = old_ifile;
                   }
   #endif /* !SMALL */
         }          }
   
         if (ifile == NULL_IFILE)          if (ifile == NULL_IFILE)
Line 263 
Line 283 
         qopen_filename = shell_unquote(open_filename);          qopen_filename = shell_unquote(open_filename);
   
         chflags = 0;          chflags = 0;
   #if !SMALL
           if (strcmp(open_filename, HELPFILE) == 0)
                   chflags |= CH_HELPFILE;
   #endif /* !SMALL */
         if (alt_pipe != NULL)          if (alt_pipe != NULL)
         {          {
                 /*                  /*
Line 312 
Line 336 
                 /*                  /*
                  * 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 342 
Line 374 
                         }                          }
                 }                  }
         }          }
         free(qopen_filename);  
   
         /*          /*
          * Get the new ifile.           * Get the new ifile.
Line 361 
Line 392 
         new_file = TRUE;          new_file = TRUE;
         ch_init(f, chflags);          ch_init(f, chflags);
   
           if (!(chflags & CH_HELPFILE))
           {
 #if LOGFILE  #if LOGFILE
         if (namelogfile != NULL && is_tty)                  if (namelogfile != NULL && is_tty)
                 use_logfile(namelogfile);                          use_logfile(namelogfile);
 #endif  #endif
         if (every_first_cmd != NULL)  #if HAVE_STAT_INO
                 ungetsc(every_first_cmd);                  /* 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)
                           ungetsc(every_first_cmd);
           }
   
           free(qopen_filename);
         no_display = !any_display;          no_display = !any_display;
         flush();          flush();
         any_display = TRUE;          any_display = TRUE;
Line 403 
Line 450 
         return (0);          return (0);
 }  }
   
 #ifndef SMALL_PROGRAM  #if EXAMINE
 /*  /*
  * Edit a space-separated list of files.   * Edit a space-separated list of files.
  * For each filename in the list, enter it into the ifile list.   * For each filename in the list, enter it into the ifile list.
Line 463 
Line 510 
         reedit_ifile(save_ifile);          reedit_ifile(save_ifile);
         return (edit(good_filename));          return (edit(good_filename));
 }  }
 #endif /* SMALL_PROGRAM */  #endif /* EXAMINE */
   
 /*  /*
  * Edit the first file in the command line (ifile) list.   * Edit the first file in the command line (ifile) list.
Line 487 
Line 534 
   
   
 /*  /*
  * 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 536 
Line 583 
         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 636 
Line 683 
          * If can't even open that, we're stuck.  Just quit.           * If can't even open that, we're stuck.  Just quit.
          */           */
         quit(QUIT_ERROR);          quit(QUIT_ERROR);
   }
   
           public void
   reopen_curr_ifile()
   {
           IFILE save_ifile = save_curr_ifile();
           close_file();
           reedit_ifile(save_ifile);
 }  }
   
 /*  /*

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8