1*40411Sbostic /*- 2*40411Sbostic * listSetCirc.c -- 3*40411Sbostic * Change the library's notion of the circularity of a list. 4*40411Sbostic * 5*40411Sbostic * Copyright (c) 1988 by the Regents of the University of California 6*40411Sbostic * 7*40411Sbostic * Copyright (c) 1988 by Adam de Boor 8*40411Sbostic * 9*40411Sbostic * Permission to use, copy, modify, and distribute this 10*40411Sbostic * software and its documentation for any purpose and without 11*40411Sbostic * fee is hereby granted, provided that the above copyright 12*40411Sbostic * notice appears in all copies. The University of California nor 13*40411Sbostic * Adam de Boor makes any representations about the suitability of this 14*40411Sbostic * software for any purpose. It is provided "as is" without 15*40411Sbostic * express or implied warranty. 16*40411Sbostic * 17*40411Sbostic * 18*40411Sbostic */ 19*40411Sbostic #ifndef lint 20*40411Sbostic static char *rcsid = 21*40411Sbostic "$Id: lstSetCirc.c,v 1.3 88/11/17 20:54:04 adam Exp $ SPRITE (Berkeley)"; 22*40411Sbostic #endif lint 23*40411Sbostic 24*40411Sbostic #include "lstInt.h" 25*40411Sbostic 26*40411Sbostic /* 27*40411Sbostic *------------------------------------------------------------ 28*40411Sbostic * Lst_SetCirc -- 29*40411Sbostic * change the circularity of a list 30*40411Sbostic * 31*40411Sbostic * Results: 32*40411Sbostic * none 33*40411Sbostic * 34*40411Sbostic * Side Effects: 35*40411Sbostic * The circularity of the list is set appropriately. The head and 36*40411Sbostic * tail of the list will be linked or unlinked as necessary 37*40411Sbostic *------------------------------------------------------------ 38*40411Sbostic */ 39*40411Sbostic void 40*40411Sbostic Lst_SetCirc (l, circ) 41*40411Sbostic Lst l; 42*40411Sbostic Boolean circ; 43*40411Sbostic { 44*40411Sbostic register List list = (List) l; 45*40411Sbostic 46*40411Sbostic /* 47*40411Sbostic * if this isn't a change, do nothing. 48*40411Sbostic */ 49*40411Sbostic if ((list->isCirc && circ) || (!list->isCirc && !circ)) { 50*40411Sbostic return; 51*40411Sbostic } 52*40411Sbostic list->isCirc = circ; 53*40411Sbostic 54*40411Sbostic if (LstIsEmpty (l)) { 55*40411Sbostic return; 56*40411Sbostic } 57*40411Sbostic 58*40411Sbostic if (circ) { 59*40411Sbostic list->firstPtr->prevPtr = list->lastPtr; 60*40411Sbostic list->lastPtr->nextPtr = list->firstPtr; 61*40411Sbostic } else { 62*40411Sbostic list->firstPtr->prevPtr = NilListNode; 63*40411Sbostic list->lastPtr->nextPtr = NilListNode; 64*40411Sbostic } 65*40411Sbostic } 66