1 /* 2 * Copyright (c) 1988, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Adam de Boor. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11 #ifndef lint 12 static char sccsid[] = "@(#)lstIsAtEnd.c 8.2 (Berkeley) 04/28/95"; 13 #endif /* not lint */ 14 15 /*- 16 * LstIsAtEnd.c -- 17 * Tell if the current node is at the end of the list. 18 * The sequential functions access the list in a slightly different way. 19 * CurPtr points to their idea of the current node in the list and they 20 * access the list based on it. Because the list is circular, Lst_Next 21 * and Lst_Prev will go around the list forever. Lst_IsAtEnd must be 22 * used to determine when to stop. 23 */ 24 25 #include "lstInt.h" 26 27 /*- 28 *----------------------------------------------------------------------- 29 * Lst_IsAtEnd -- 30 * Return true if have reached the end of the given list. 31 * 32 * Results: 33 * TRUE if at the end of the list (this includes the list not being 34 * open or being invalid) or FALSE if not. We return TRUE if the list 35 * is invalid or unopend so as to cause the caller to exit its loop 36 * asap, the assumption being that the loop is of the form 37 * while (!Lst_IsAtEnd (l)) { 38 * ... 39 * } 40 * 41 * Side Effects: 42 * None. 43 * 44 *----------------------------------------------------------------------- 45 */ 46 Boolean 47 Lst_IsAtEnd (l) 48 Lst l; 49 { 50 register List list = (List) l; 51 52 return (!LstValid (l) || !list->isOpen || 53 (list->atEnd == Head) || (list->atEnd == Tail)); 54 } 55 56