=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/ifile.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.2 diff -u -r1.1.1.1 -r1.1.1.2 --- src/usr.bin/less/ifile.c 1996/09/21 05:39:42 1.1.1.1 +++ src/usr.bin/less/ifile.c 2003/04/13 18:21:21 1.1.1.2 @@ -1,27 +1,11 @@ /* - * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman - * All rights reserved. + * Copyright (C) 1984-2002 Mark Nudelman * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * 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. + * You may distribute under the terms of either the GNU General Public + * License or the Less License, as specified in the README file. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * 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. + * For more information about less, or for information on how to + * contact the author, see the README file. */ @@ -46,7 +30,8 @@ char *h_filename; /* Name of the file */ void *h_filestate; /* File state (used in ch.c) */ 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 */ }; @@ -60,7 +45,8 @@ /* * 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 void @@ -72,6 +58,9 @@ p->h_index += incr; } +/* + * Link an ifile into the ifile list. + */ static void link_ifile(p, prev) struct ifile *p; @@ -95,6 +84,9 @@ ifiles++; } +/* + * Unlink an ifile from the ifile list. + */ static void unlink_ifile(p) struct ifile *p; @@ -125,6 +117,8 @@ p->h_filename = save(filename); p->h_scrpos.pos = NULL_POSITION; p->h_opened = 0; + p->h_hold = 0; + p->h_filestate = NULL; link_ifile(p, prev); return (p); } @@ -144,6 +138,7 @@ * If the ifile we're deleting is the currently open ifile, * move off it. */ + unmark(h); if (h == curr_ifile) curr_ifile = getoff_ifile(curr_ifile); p = int_ifile(h); @@ -302,6 +297,21 @@ IFILE ifile; { 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 *