1 /*
2 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Adam de Boor.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the University of California, Berkeley. The name of the
14 * University may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 */
20
21 #ifndef lint
22 static char sccsid[] = "@(#)lstSetCirc.c 5.2 (Berkeley) 03/11/90";
23 #endif /* not lint */
24
25 /*-
26 * listSetCirc.c --
27 * Change the library's notion of the circularity of a list.
28 */
29
30 #include "lstInt.h"
31
32 /*
33 *------------------------------------------------------------
34 * Lst_SetCirc --
35 * change the circularity of a list
36 *
37 * Results:
38 * none
39 *
40 * Side Effects:
41 * The circularity of the list is set appropriately. The head and
42 * tail of the list will be linked or unlinked as necessary
43 *------------------------------------------------------------
44 */
45 void
Lst_SetCirc(l,circ)46 Lst_SetCirc (l, circ)
47 Lst l;
48 Boolean circ;
49 {
50 register List list = (List) l;
51
52 /*
53 * if this isn't a change, do nothing.
54 */
55 if ((list->isCirc && circ) || (!list->isCirc && !circ)) {
56 return;
57 }
58 list->isCirc = circ;
59
60 if (LstIsEmpty (l)) {
61 return;
62 }
63
64 if (circ) {
65 list->firstPtr->prevPtr = list->lastPtr;
66 list->lastPtr->nextPtr = list->firstPtr;
67 } else {
68 list->firstPtr->prevPtr = NilListNode;
69 list->lastPtr->nextPtr = NilListNode;
70 }
71 }
72