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

Diff for /src/usr.bin/less/ifile.c between version 1.3 and 1.4

version 1.3, 2001/11/19 19:02:14 version 1.4, 2003/04/13 18:26:25
Line 1 
Line 1 
 /*      $OpenBSD$       */  
   
 /*  /*
  * Copyright (c) 1984,1985,1989,1994,1995  Mark Nudelman   * Copyright (C) 1984-2002  Mark Nudelman
  * All rights reserved.  
  *   *
  * Redistribution and use in source and binary forms, with or without   * You may distribute under the terms of either the GNU General Public
  * modification, are permitted provided that the following conditions   * License or the Less License, as specified in the README file.
  * are met:  
  * 1. Redistributions of source code must retain the above copyright  
  *    notice, this list of conditions and the following disclaimer.  
  * 2. Redistributions in binary form must reproduce the above copyright  
  *    notice in the documentation and/or other materials provided with  
  *    the distribution.  
  *   *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY   * For more information about less, or for information on how to
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE   * contact the author, see the README file.
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE  
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  
  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  
  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR  
  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN  
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
  */   */
   
   
Line 48 
Line 30 
         char *h_filename;               /* Name of the file */          char *h_filename;               /* Name of the file */
         void *h_filestate;              /* File state (used in ch.c) */          void *h_filestate;              /* File state (used in ch.c) */
         int h_index;                    /* Index within command line list */          int h_index;                    /* Index within command line list */
         int h_opened;                   /* Only need one bit */          int h_hold;                     /* Hold count */
           char h_opened;                  /* Has this ifile been opened? */
         struct scrpos h_scrpos;         /* Saved position within the file */          struct scrpos h_scrpos;         /* Saved position within the file */
 };  };
   
Line 62 
Line 45 
 /*  /*
  * Anchor for linked list.   * Anchor for linked list.
  */   */
 static struct ifile anchor = { &anchor, &anchor, 0 };  static struct ifile anchor = { &anchor, &anchor, NULL, NULL, 0, 0, '\0',
                                   { NULL_POSITION, 0 } };
 static int ifiles = 0;  static int ifiles = 0;
   
         static void          static void
 incr_index(p, incr)  incr_index(p, incr)
         struct ifile *p;          register struct ifile *p;
         int incr;          int incr;
 {  {
         for (;  p != &anchor;  p = p->h_next)          for (;  p != &anchor;  p = p->h_next)
                 p->h_index += incr;                  p->h_index += incr;
 }  }
   
   /*
    * Link an ifile into the ifile list.
    */
         static void          static void
 link_ifile(p, prev)  link_ifile(p, prev)
         struct ifile *p;          struct ifile *p;
Line 97 
Line 84 
         ifiles++;          ifiles++;
 }  }
   
   /*
    * Unlink an ifile from the ifile list.
    */
         static void          static void
 unlink_ifile(p)  unlink_ifile(p)
         struct ifile *p;          struct ifile *p;
Line 118 
Line 108 
         char *filename;          char *filename;
         struct ifile *prev;          struct ifile *prev;
 {  {
         struct ifile *p;          register struct ifile *p;
   
         /*          /*
          * Allocate and initialize structure.           * Allocate and initialize structure.
Line 127 
Line 117 
         p->h_filename = save(filename);          p->h_filename = save(filename);
         p->h_scrpos.pos = NULL_POSITION;          p->h_scrpos.pos = NULL_POSITION;
         p->h_opened = 0;          p->h_opened = 0;
           p->h_hold = 0;
           p->h_filestate = NULL;
         link_ifile(p, prev);          link_ifile(p, prev);
         return (p);          return (p);
 }  }
Line 138 
Line 130 
 del_ifile(h)  del_ifile(h)
         IFILE h;          IFILE h;
 {  {
         struct ifile *p;          register struct ifile *p;
   
         if (h == NULL_IFILE)          if (h == NULL_IFILE)
                 return;                  return;
Line 146 
Line 138 
          * If the ifile we're deleting is the currently open ifile,           * If the ifile we're deleting is the currently open ifile,
          * move off it.           * move off it.
          */           */
           unmark(h);
         if (h == curr_ifile)          if (h == curr_ifile)
                 curr_ifile = getoff_ifile(curr_ifile);                  curr_ifile = getoff_ifile(curr_ifile);
         p = int_ifile(h);          p = int_ifile(h);
Line 161 
Line 154 
 next_ifile(h)  next_ifile(h)
         IFILE h;          IFILE h;
 {  {
         struct ifile *p;          register struct ifile *p;
   
         p = (h == NULL_IFILE) ? &anchor : int_ifile(h);          p = (h == NULL_IFILE) ? &anchor : int_ifile(h);
         if (p->h_next == &anchor)          if (p->h_next == &anchor)
Line 176 
Line 169 
 prev_ifile(h)  prev_ifile(h)
         IFILE h;          IFILE h;
 {  {
         struct ifile *p;          register struct ifile *p;
   
         p = (h == NULL_IFILE) ? &anchor : int_ifile(h);          p = (h == NULL_IFILE) ? &anchor : int_ifile(h);
         if (p->h_prev == &anchor)          if (p->h_prev == &anchor)
Line 216 
Line 209 
 find_ifile(filename)  find_ifile(filename)
         char *filename;          char *filename;
 {  {
         struct ifile *p;          register struct ifile *p;
   
         for (p = anchor.h_next;  p != &anchor;  p = p->h_next)          for (p = anchor.h_next;  p != &anchor;  p = p->h_next)
                 if (strcmp(filename, p->h_filename) == 0)                  if (strcmp(filename, p->h_filename) == 0)
Line 234 
Line 227 
         char *filename;          char *filename;
         IFILE prev;          IFILE prev;
 {  {
         struct ifile *p;          register struct ifile *p;
   
         if ((p = find_ifile(filename)) == NULL)          if ((p = find_ifile(filename)) == NULL)
                 p = new_ifile(filename, int_ifile(prev));                  p = new_ifile(filename, int_ifile(prev));
Line 306 
Line 299 
         return (int_ifile(ifile)->h_opened);          return (int_ifile(ifile)->h_opened);
 }  }
   
           public void
   hold_ifile(ifile, incr)
           IFILE ifile;
           int incr;
   {
           int_ifile(ifile)->h_hold += incr;
   }
   
           public int
   held_ifile(ifile)
           IFILE ifile;
   {
           return (int_ifile(ifile)->h_hold);
   }
   
         public void *          public void *
 get_filestate(ifile)  get_filestate(ifile)
         IFILE ifile;          IFILE ifile;
Line 325 
Line 333 
         public void          public void
 if_dump()  if_dump()
 {  {
         struct ifile *p;          register struct ifile *p;
   
         for (p = anchor.h_next;  p != &anchor;  p = p->h_next)          for (p = anchor.h_next;  p != &anchor;  p = p->h_next)
         {          {

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4