xref: /original-bsd/usr.bin/make/lst.lib/lstLast.c (revision 0842ddeb)
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[] = "@(#)lstLast.c	8.2 (Berkeley) 04/28/95";
13 #endif /* not lint */
14 
15 /*-
16  * LstLast.c --
17  *	Return the last element of a list
18  */
19 
20 #include	"lstInt.h"
21 
22 /*-
23  *-----------------------------------------------------------------------
24  * Lst_Last --
25  *	Return the last node on the list l.
26  *
27  * Results:
28  *	The requested node or NILLNODE if the list is empty.
29  *
30  * Side Effects:
31  *	None.
32  *
33  *-----------------------------------------------------------------------
34  */
35 LstNode
36 Lst_Last (l)
37     Lst	    l;
38 {
39     if (!LstValid(l) || LstIsEmpty (l)) {
40 	return (NILLNODE);
41     } else {
42 	return ((LstNode)((List)l)->lastPtr);
43     }
44 }
45 
46