From b858e5c4eaf64a7a0c90c27112d9eb8caec293f8 Mon Sep 17 00:00:00 2001 From: Max Okumoto Date: Sat, 12 Mar 2005 10:20:38 +0000 Subject: [PATCH] Style: fix indentation of SuffExpandChildren before working on it. FreeBSD-Date: 2005/03/08 16:30:32 Author: harti --- usr.bin/make/suff.c | 374 +++++++++++++++++++++++--------------------- 1 file changed, 195 insertions(+), 179 deletions(-) diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 934b989ef9..7617bc438a 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -37,7 +37,7 @@ * * @(#)suff.c 8.4 (Berkeley) 3/21/94 * $FreeBSD: src/usr.bin/make/suff.c,v 1.43 2005/02/04 13:23:39 harti Exp $ - * $DragonFly: src/usr.bin/make/suff.c,v 1.35 2005/02/28 12:00:10 okumoto Exp $ + * $DragonFly: src/usr.bin/make/suff.c,v 1.36 2005/03/12 10:20:38 okumoto Exp $ */ /*- @@ -1290,207 +1290,223 @@ SuffFindCmds(Src *targ, Lst *slst) static int SuffExpandChildren(void *cgnp, void *pgnp) { - GNode *cgn = cgnp; - GNode *pgn = pgnp; - GNode *gn; /* New source 8) */ - LstNode *prevLN; /* Node after which new source should be put */ - LstNode *ln; /* List element for old source */ - char *cp; /* Expanded value */ - Buffer *buf; + GNode *cgn = cgnp; + GNode *pgn = pgnp; + GNode *gn; /* New source 8) */ + LstNode *prevLN; /* Node after which new source should be put */ + LstNode *ln; /* List element for old source */ + char *cp; /* Expanded value */ + Buffer *buf; - /* - * New nodes effectively take the place of the child, so place them - * after the child - */ - prevLN = Lst_Member(&pgn->children, cgn); - - /* - * First do variable expansion -- this takes precedence over - * wildcard expansion. If the result contains wildcards, they'll be gotten - * to later since the resulting words are tacked on to the end of - * the children list. - */ - if (strchr(cgn->name, '$') != NULL) { - DEBUGF(SUFF, ("Expanding \"%s\"...", cgn->name)); - buf = Var_Subst(NULL, cgn->name, pgn, TRUE); - cp = Buf_GetAll(buf, NULL); - Buf_Destroy(buf, FALSE); - - if (cp != NULL) { - Lst members = Lst_Initializer(members); - - if (cgn->type & OP_ARCHV) { - /* - * Node was an archive(member) target, so we want to call - * on the Arch module to find the nodes for us, expanding - * variables in the parent's context. - */ - char *sacrifice = cp; - - Arch_ParseArchive(&sacrifice, &members, pgn); - } else { - /* - * Break the result into a vector of strings whose nodes - * we can find, then add those nodes to the members list. - * Unfortunately, we can't use brk_string b/c it - * doesn't understand about variable specifications with - * spaces in them... - */ - char *start; - char *initcp = cp; /* For freeing... */ + /* + * New nodes effectively take the place of the child, so place them + * after the child + */ + prevLN = Lst_Member(&pgn->children, cgn); - for (start = cp; *start == ' ' || *start == '\t'; start++) - continue; - for (cp = start; *cp != '\0'; cp++) { - if (*cp == ' ' || *cp == '\t') { - /* - * White-space -- terminate element, find the node, - * add it, skip any further spaces. - */ - *cp++ = '\0'; - gn = Targ_FindNode(start, TARG_CREATE); - Lst_AtEnd(&members, gn); - while (*cp == ' ' || *cp == '\t') { - cp++; + /* + * First do variable expansion -- this takes precedence over + * wildcard expansion. If the result contains wildcards, they'll be + * gotten to later since the resulting words are tacked on to the + * end of the children list. + */ + if (strchr(cgn->name, '$') != NULL) { + DEBUGF(SUFF, ("Expanding \"%s\"...", cgn->name)); + buf = Var_Subst(NULL, cgn->name, pgn, TRUE); + cp = Buf_GetAll(buf, NULL); + Buf_Destroy(buf, FALSE); + + if (cp != NULL) { + Lst members = Lst_Initializer(members); + + if (cgn->type & OP_ARCHV) { + /* + * Node was an archive(member) target, so we + * want to call on the Arch module to find the + * nodes for us, expanding variables in the + * parent's context. + */ + char *sacrifice = cp; + + Arch_ParseArchive(&sacrifice, &members, pgn); + } else { + /* + * Break the result into a vector of strings + * whose nodes we can find, then add those + * nodes to the members list. Unfortunately, + * we can't use brk_string b/c it doesn't + * understand about variable specifications with + * spaces in them... + */ + char *start; + char *initcp = cp; /* For freeing... */ + + for (start = cp; *start == ' ' || + *start == '\t'; start++) + continue; + for (cp = start; *cp != '\0'; cp++) { + if (*cp == ' ' || *cp == '\t') { + /* + * White-space -- terminate + * element, find the node, + * add it, skip any further + * spaces. + */ + *cp++ = '\0'; + gn = Targ_FindNode(start, + TARG_CREATE); + Lst_AtEnd(&members, gn); + while (*cp == ' ' || + *cp == '\t') { + cp++; + } + /* + * Adjust cp for increment at + * start of loop, but set start + * to first non-space. + */ + start = cp--; + + } else if (*cp == '$') { + /* + * Start of a variable spec -- + * contact variable module + * to find the end so we can + * skip over it. + */ + char *junk; + size_t len = 0; + Boolean doFree; + + junk = Var_Parse(cp, pgn, TRUE, + &len, &doFree); + if (junk != var_Error) { + cp += len - 1; + } + if (doFree) { + free(junk); + } + + } else if (*cp == '\\' && *cp != '\0') { + /* + * Escaped something -- skip + * over it + */ + cp++; + } + } + + if (cp != start) { + /* + * Stuff left over -- add it to the + * list too + */ + gn = Targ_FindNode(start, TARG_CREATE); + Lst_AtEnd(&members, gn); + } + /* + * Point cp back at the beginning again so the + * variable value can be freed. + */ + cp = initcp; } /* - * Adjust cp for increment at start of loop, but - * set start to first non-space. + * Add all elements of the members list to + * the parent node. */ - start = cp--; - } else if (*cp == '$') { - /* - * Start of a variable spec -- contact variable module - * to find the end so we can skip over it. - */ - char *junk; - size_t len = 0; - Boolean doFree; - - junk = Var_Parse(cp, pgn, TRUE, &len, &doFree); - if (junk != var_Error) { - cp += len - 1; + while(!Lst_IsEmpty(&members)) { + gn = Lst_DeQueue(&members); + + DEBUGF(SUFF, ("%s...", gn->name)); + if (Lst_Member(&pgn->children, gn) == NULL) { + Lst_Append(&pgn->children, prevLN, gn); + prevLN = Lst_Succ(prevLN); + Lst_AtEnd(&gn->parents, pgn); + pgn->unmade++; + } } - if (doFree) { - free(junk); - } - } else if (*cp == '\\' && *cp != '\0') { /* - * Escaped something -- skip over it + * Free the result */ - cp++; - } - } - - if (cp != start) { - /* - * Stuff left over -- add it to the list too - */ - gn = Targ_FindNode(start, TARG_CREATE); - Lst_AtEnd(&members, gn); + free(cp); } /* - * Point cp back at the beginning again so the variable value - * can be freed. + * Now the source is expanded, remove it from the list + * of children to keep it from being processed. */ - cp = initcp; - } - /* - * Add all elements of the members list to the parent node. - */ - while(!Lst_IsEmpty(&members)) { - gn = Lst_DeQueue(&members); - - DEBUGF(SUFF, ("%s...", gn->name)); - if (Lst_Member(&pgn->children, gn) == NULL) { - Lst_Append(&pgn->children, prevLN, gn); - prevLN = Lst_Succ(prevLN); - Lst_AtEnd(&gn->parents, pgn); - pgn->unmade++; - } - } + ln = Lst_Member(&pgn->children, cgn); + pgn->unmade--; + Lst_Remove(&pgn->children, ln); + DEBUGF(SUFF, ("\n")); - /* - * Free the result - */ - free(cp); - } - /* - * Now the source is expanded, remove it from the list of children to - * keep it from being processed. - */ - ln = Lst_Member(&pgn->children, cgn); - pgn->unmade--; - Lst_Remove(&pgn->children, ln); - DEBUGF(SUFF, ("\n")); - } else if (Dir_HasWildcards(cgn->name)) { - Lst exp; /* List of expansions */ - Lst *path; /* Search path along which to expand */ + } else if (Dir_HasWildcards(cgn->name)) { + Lst exp; /* List of expansions */ + Lst *path; /* Search path along which to expand */ - /* - * Find a path along which to expand the word. - * - * If the word has a known suffix, use that path. - * If it has no known suffix and we're allowed to use the null - * suffix, use its path. - * Else use the default system search path. - */ - cp = cgn->name + strlen(cgn->name); - ln = Lst_Find(&sufflist, cp, SuffSuffIsSuffixP); + /* + * Find a path along which to expand the word. + * + * If the word has a known suffix, use that path. + * If it has no known suffix and we're allowed to use the null + * suffix, use its path. + * Else use the default system search path. + */ + cp = cgn->name + strlen(cgn->name); + ln = Lst_Find(&sufflist, cp, SuffSuffIsSuffixP); - DEBUGF(SUFF, ("Wildcard expanding \"%s\"...", cgn->name)); + DEBUGF(SUFF, ("Wildcard expanding \"%s\"...", cgn->name)); - if (ln != NULL) { - Suff *s = Lst_Datum(ln); + if (ln != NULL) { + Suff *s = Lst_Datum(ln); - DEBUGF(SUFF, ("suffix is \"%s\"...", s->name)); - path = &s->searchPath; - } else { - /* - * Use default search path - */ - path = &dirSearchPath; - } + DEBUGF(SUFF, ("suffix is \"%s\"...", s->name)); + path = &s->searchPath; + } else { + /* + * Use default search path + */ + path = &dirSearchPath; + } - /* - * Expand the word along the chosen path - */ - Lst_Init(&exp); - Dir_Expand(cgn->name, path, &exp); + /* + * Expand the word along the chosen path + */ + Lst_Init(&exp); + Dir_Expand(cgn->name, path, &exp); - while (!Lst_IsEmpty(&exp)) { - /* - * Fetch next expansion off the list and find its GNode - */ - cp = Lst_DeQueue(&exp); + while (!Lst_IsEmpty(&exp)) { + /* + * Fetch next expansion off the list and find its GNode + */ + cp = Lst_DeQueue(&exp); - DEBUGF(SUFF, ("%s...", cp)); - gn = Targ_FindNode(cp, TARG_CREATE); + DEBUGF(SUFF, ("%s...", cp)); + gn = Targ_FindNode(cp, TARG_CREATE); - /* - * If gn isn't already a child of the parent, make it so and - * up the parent's count of unmade children. - */ - if (Lst_Member(&pgn->children, gn) == NULL) { - Lst_Append(&pgn->children, prevLN, gn); - prevLN = Lst_Succ(prevLN); - Lst_AtEnd(&gn->parents, pgn); - pgn->unmade++; - } - } + /* + * If gn isn't already a child of the parent, make it + * so and up the parent's count of unmade children. + */ + if (Lst_Member(&pgn->children, gn) == NULL) { + Lst_Append(&pgn->children, prevLN, gn); + prevLN = Lst_Succ(prevLN); + Lst_AtEnd(&gn->parents, pgn); + pgn->unmade++; + } + } - /* - * Now the source is expanded, remove it from the list of children to - * keep it from being processed. - */ - ln = Lst_Member(&pgn->children, cgn); - pgn->unmade--; - Lst_Remove(&pgn->children, ln); - DEBUGF(SUFF, ("\n")); - } + /* + * Now the source is expanded, remove it from the list of + * children to keep it from being processed. + */ + ln = Lst_Member(&pgn->children, cgn); + pgn->unmade--; + Lst_Remove(&pgn->children, ln); + DEBUGF(SUFF, ("\n")); + } - return (0); + return (0); } /*- -- 2.41.0