1 /*- 2 * LstIsAtEnd.c -- 3 * Tell if the current node is at the end of the list. 4 * The sequential functions access the list in a slightly different way. 5 * CurPtr points to their idea of the current node in the list and they 6 * access the list based on it. Because the list is circular, Lst_Next 7 * and Lst_Prev will go around the list forever. Lst_IsAtEnd must be 8 * used to determine when to stop. 9 * 10 * Copyright (c) 1988 by University of California Regents 11 * 12 * Permission to use, copy, modify, and distribute this 13 * software and its documentation for any purpose and without 14 * fee is hereby granted, provided that the above copyright 15 * notice appears in all copies. Neither the University of California nor 16 * Adam de Boor makes any representations about the suitability of this 17 * software for any purpose. It is provided "as is" without 18 * express or implied warranty. 19 */ 20 #ifndef lint 21 static char *rcsid = 22 "$Id: lstIsAtEnd.c,v 1.6 88/11/17 20:53:14 adam Exp $ SPRITE (Berkeley)"; 23 #endif lint 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