Module Name: src
Committed By: rillig
Date: Wed Oct 21 07:11:51 UTC 2020
Modified Files:
src/usr.bin/make: suff.c
Log Message:
make(1): clean up suffix handling code
Using (name, nameLen) is easier to understand than the unusual (nameLen,
nameEnd).
To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/usr.bin/make/suff.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.207 src/usr.bin/make/suff.c:1.208
--- src/usr.bin/make/suff.c:1.207 Wed Oct 21 07:05:52 2020
+++ src/usr.bin/make/suff.c Wed Oct 21 07:11:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.207 2020/10/21 07:05:52 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.208 2020/10/21 07:11:50 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.207 2020/10/21 07:05:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.208 2020/10/21 07:11:50 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -1585,15 +1585,15 @@ SuffFindArchiveDeps(GNode *gn, SrcList *
}
static void
-SuffFindNormalDepsKnown(size_t nameLen, char *nameEnd, GNode *gn,
- const char *sopref, SrcList *srcs, SrcList *targs)
+SuffFindNormalDepsKnown(char *name, size_t nameLen, GNode *gn,
+ SrcList *srcs, SrcList *targs)
{
SuffListNode *ln;
const char *eopref;
Src *targ;
for (ln = sufflist->first; ln != NULL; ln = ln->next) {
- if (!SuffSuffIsSuffix(ln->datum, nameLen, nameEnd))
+ if (!SuffSuffIsSuffix(ln->datum, nameLen, name + nameLen))
continue;
targ = bmake_malloc(sizeof(Src));
@@ -1607,8 +1607,8 @@ SuffFindNormalDepsKnown(size_t nameLen,
targ->cp = Lst_New();
#endif
- eopref = nameEnd - targ->suff->nameLen;
- targ->pref = bmake_strsedup(sopref, eopref);
+ eopref = name + nameLen - targ->suff->nameLen;
+ targ->pref = bmake_strsedup(name, eopref);
/*
* Add nodes from which the target can be made
@@ -1745,9 +1745,8 @@ SuffFindNormalDeps(GNode *gn, SrcList *s
char *pref; /* Prefix to use */
Src *targ; /* General Src target pointer */
- size_t nameLen = strlen(gn->name);
- char *eoname = gn->name + nameLen;
- char *sopref = gn->name;
+ char *name = gn->name;
+ size_t nameLen = strlen(name);
/*
* Begin at the beginning...
@@ -1778,10 +1777,10 @@ SuffFindNormalDeps(GNode *gn, SrcList *s
if (!(gn->type & OP_PHONY)) {
- SuffFindNormalDepsKnown(nameLen, eoname, gn, sopref, srcs, targs);
+ SuffFindNormalDepsKnown(name, nameLen, gn, srcs, targs);
/* Handle target of unknown suffix... */
- SuffFindNormalDepsUnknown(gn, sopref, srcs, targs);
+ SuffFindNormalDepsUnknown(gn, name, srcs, targs);
/*
* Using the list of possible sources built up from the target