Reindent search loop in SuffFindCmds using 'continue' and 'break' instead

of netsted ifs.  No logic change.
This commit is contained in:
dsl 2004-01-11 17:24:25 +00:00
parent 7fac3a4aea
commit 4169574d6f

View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.42 2003/08/07 11:14:57 agc Exp $ */ /* $NetBSD: suff.c,v 1.43 2004/01/11 17:24:25 dsl Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/ */
#ifdef MAKE_BOOTSTRAP #ifdef MAKE_BOOTSTRAP
static char rcsid[] = "$NetBSD: suff.c,v 1.42 2003/08/07 11:14:57 agc Exp $"; static char rcsid[] = "$NetBSD: suff.c,v 1.43 2004/01/11 17:24:25 dsl Exp $";
#else #else
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else #else
__RCSID("$NetBSD: suff.c,v 1.42 2003/08/07 11:14:57 agc Exp $"); __RCSID("$NetBSD: suff.c,v 1.43 2004/01/11 17:24:25 dsl Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
#endif #endif
@ -1417,7 +1417,12 @@ SuffFindCmds(Src *targ, Lst slst)
(void) Lst_Open (t->children); (void) Lst_Open (t->children);
prefLen = strlen (targ->pref); prefLen = strlen (targ->pref);
while ((ln = Lst_Next (t->children)) != NILLNODE) { for (;;) {
ln = Lst_Next(t->children);
if (ln == NILLNODE) {
Lst_Close (t->children);
return NULL;
}
s = (GNode *)Lst_Datum (ln); s = (GNode *)Lst_Datum (ln);
cp = strrchr (s->name, '/'); cp = strrchr (s->name, '/');
@ -1426,56 +1431,53 @@ SuffFindCmds(Src *targ, Lst slst)
} else { } else {
cp++; cp++;
} }
if (strncmp (cp, targ->pref, prefLen) == 0) { if (strncmp (cp, targ->pref, prefLen) != 0)
/* continue;
* The node matches the prefix ok, see if it has a known /*
* suffix. * The node matches the prefix ok, see if it has a known
*/ * suffix.
ln = Lst_Find (sufflist, (ClientData)&cp[prefLen], */
SuffSuffHasNameP); ln = Lst_Find (sufflist, (ClientData)&cp[prefLen],
if (ln != NILLNODE) { SuffSuffHasNameP);
/* if (ln == NILLNODE)
* It even has a known suffix, see if there's a transformation continue;
* defined between the node's suffix and the target's suffix. /*
* * It even has a known suffix, see if there's a transformation
* XXX: Handle multi-stage transformations here, too. * defined between the node's suffix and the target's suffix.
*/ *
suff = (Suff *)Lst_Datum (ln); * XXX: Handle multi-stage transformations here, too.
*/
suff = (Suff *)Lst_Datum (ln);
if (Lst_Member (suff->parents, if (Lst_Member(suff->parents, (ClientData)targ->suff) != NILLNODE)
(ClientData)targ->suff) != NILLNODE) break;
{
/*
* Hot Damn! Create a new Src structure to describe
* this transformation (making sure to duplicate the
* source node's name so Suff_FindDeps can free it
* again (ick)), and return the new structure.
*/
ret = (Src *)emalloc (sizeof (Src));
ret->file = estrdup(s->name);
ret->pref = targ->pref;
ret->suff = suff;
suff->refCount++;
ret->parent = targ;
ret->node = s;
ret->children = 0;
targ->children += 1;
#ifdef DEBUG_SRC
ret->cp = Lst_Init(FALSE);
printf("3 add %x %x\n", targ, ret);
Lst_AtEnd(targ->cp, (ClientData) ret);
#endif
Lst_AtEnd(slst, (ClientData) ret);
if (DEBUG(SUFF)) {
printf ("\tusing existing source %s\n", s->name);
}
return (ret);
}
}
}
} }
Lst_Close (t->children);
return ((Src *)NULL); /*
* Hot Damn! Create a new Src structure to describe
* this transformation (making sure to duplicate the
* source node's name so Suff_FindDeps can free it
* again (ick)), and return the new structure.
*/
ret = (Src *)emalloc (sizeof (Src));
ret->file = estrdup(s->name);
ret->pref = targ->pref;
ret->suff = suff;
suff->refCount++;
ret->parent = targ;
ret->node = s;
ret->children = 0;
targ->children += 1;
#ifdef DEBUG_SRC
ret->cp = Lst_Init(FALSE);
printf("3 add %x %x\n", targ, ret);
Lst_AtEnd(targ->cp, (ClientData) ret);
#endif
Lst_AtEnd(slst, (ClientData) ret);
if (DEBUG(SUFF)) {
printf ("\tusing existing source %s\n", s->name);
}
return (ret);
} }
/*- /*-