summaryrefslogtreecommitdiff
path: root/usr.bin/make/lst.lib/lstFindFrom.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/make/lst.lib/lstFindFrom.c')
-rw-r--r--usr.bin/make/lst.lib/lstFindFrom.c52
1 files changed, 16 insertions, 36 deletions
diff --git a/usr.bin/make/lst.lib/lstFindFrom.c b/usr.bin/make/lst.lib/lstFindFrom.c
index ba033c291fa..8ef31a77330 100644
--- a/usr.bin/make/lst.lib/lstFindFrom.c
+++ b/usr.bin/make/lst.lib/lstFindFrom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lstFindFrom.c,v 1.5 1999/12/18 21:53:33 espie Exp $ */
+/* $OpenBSD: lstFindFrom.c,v 1.6 1999/12/19 00:04:26 espie Exp $ */
/* $NetBSD: lstFindFrom.c,v 1.6 1996/11/06 17:59:40 christos Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)lstFindFrom.c 8.1 (Berkeley) 6/6/93";
#else
-static char *rcsid = "$OpenBSD: lstFindFrom.c,v 1.5 1999/12/18 21:53:33 espie Exp $";
+static char *rcsid = "$OpenBSD: lstFindFrom.c,v 1.6 1999/12/19 00:04:26 espie Exp $";
#endif
#endif /* not lint */
@@ -55,47 +55,27 @@ static char *rcsid = "$OpenBSD: lstFindFrom.c,v 1.5 1999/12/18 21:53:33 espie Ex
/*-
*-----------------------------------------------------------------------
* Lst_FindFrom --
- * Search for a node starting and ending with the given one on the
- * given list using the passed datum and comparison function to
- * determine when it has been found.
+ * Search for a node through a list, starting with the given node,
+ * using the comparison function and passed datum to determine when
+ * it has been found.
*
* Results:
- * The found node or NULL
+ * The node if found, or NULL
*
* Side Effects:
- * None.
- *
+ * Whatever cProc incurs.
*-----------------------------------------------------------------------
*/
LstNode
-Lst_FindFrom (l, ln, d, cProc)
- Lst l;
- register LstNode ln;
- register ClientData d;
- register int (*cProc) __P((ClientData, ClientData));
+Lst_FindFrom(ln, cProc, d)
+ LstNode ln;
+ FindProc cProc;
+ ClientData d;
{
- register ListNode tln;
- Boolean found = FALSE;
-
- if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
- return (NULL);
- }
-
- tln = (ListNode)ln;
+ ListNode tln;
- do {
- if ((*cProc) (tln->datum, d) == 0) {
- found = TRUE;
- break;
- } else {
- tln = tln->nextPtr;
- }
- } while (tln != (ListNode)ln && tln != NULL);
-
- if (found) {
- return ((LstNode)tln);
- } else {
- return (NULL);
- }
+ for (tln = (ListNode)ln; tln != NULL; tln = tln->nextPtr)
+ if ((*cProc)(tln->datum, d) == 0)
+ return (LstNode)tln;
+ return NULL;
}
-