Module Name: othersrc Committed By: dholland Date: Sat Mar 23 18:02:58 UTC 2013
Modified Files: othersrc/usr.bin/dholland-make2: suff.c Log Message: Simplify the interface to SuffSuffIsSuffix(). To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 othersrc/usr.bin/dholland-make2/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: othersrc/usr.bin/dholland-make2/suff.c diff -u othersrc/usr.bin/dholland-make2/suff.c:1.14 othersrc/usr.bin/dholland-make2/suff.c:1.15 --- othersrc/usr.bin/dholland-make2/suff.c:1.14 Sat Mar 23 17:56:58 2013 +++ othersrc/usr.bin/dholland-make2/suff.c Sat Mar 23 18:02:58 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.14 2013/03/23 17:56:58 dholland Exp $ */ +/* $NetBSD: suff.c,v 1.15 2013/03/23 18:02:58 dholland Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,7 +131,7 @@ #include "hash.h" #include "dir.h" -MAKE_RCSID("$NetBSD: suff.c,v 1.14 2013/03/23 17:56:58 dholland Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.15 2013/03/23 18:02:58 dholland Exp $"); #define CLEANUP @@ -159,14 +159,6 @@ typedef struct Suff { } Suff; /* - * for SuffSuffIsSuffix - */ -typedef struct { - const char *ename; /* The end of the name */ - int len; /* Length of the name */ -} SuffixCmpData; - -/* * Structure used in the search for implied sources. */ @@ -215,7 +207,7 @@ static Suff *emptySuff; /* The empt static const char *SuffStrIsPrefix(const char *, const char *); -static const char *SuffSuffIsSuffix(const Suff *, const SuffixCmpData *); +static const char *SuffSuffIsSuffix(const Suff *, const char *name); static void SuffUnRef(struct sufflist *, Suff *); static void SuffFree(void *); static void SuffInsert(struct sufflist *, Suff *); @@ -284,16 +276,18 @@ SuffStrIsPrefix(const char *pref, const *----------------------------------------------------------------------- */ static const char * -SuffSuffIsSuffix(const Suff *s, const SuffixCmpData *sd) +SuffSuffIsSuffix(const Suff *s, const char *name) { + size_t namelen; const char *p1; /* Pointer into suffix name */ const char *p2; /* Pointer into string being examined */ - if (sd->len < s->nameLen) + namelen = strlen(name); + if (namelen < s->nameLen) return NULL; /* this string is shorter than the suffix */ p1 = s->name + s->nameLen; - p2 = sd->ename; + p2 = name + namelen; while (p1 >= s->name && *p1 == *p2) { p1--; @@ -794,7 +788,6 @@ SuffRebuildGraph(GNode *transform, Suff { const char *cp; Suff *s2; - SuffixCmpData sd; unsigned i, numsuffixes; size_t matchlen; @@ -822,9 +815,7 @@ SuffRebuildGraph(GNode *transform, Suff /* * Not from, maybe to? */ - sd.len = strlen(transform->name); - sd.ename = transform->name + sd.len; - cp = SuffSuffIsSuffix(s, &sd); + cp = SuffSuffIsSuffix(s, transform->name); if (cp != NULL) { /* * For reasons best known to whoever wrote it, @@ -948,15 +939,11 @@ SuffFindBySuffix(struct sufflist *list, { unsigned i, num; Suff *s; - SuffixCmpData sd; /* Search string data */ - - sd.len = strlen(name); - sd.ename = name + sd.len; num = sufflist_num(list); for (i=0; i<num; i++) { s = sufflist_get(list, i); - if (SuffSuffIsSuffix(s, &sd) != NULL) { + if (SuffSuffIsSuffix(s, name) != NULL) { return s; } } @@ -2078,13 +2065,11 @@ SuffFindNormalDeps(GNode *gn, struct src Src *src; /* General Src pointer */ char *pref; /* Prefix to use */ Src *targ; /* General Src target pointer */ - SuffixCmpData sd; /* Search string data */ unsigned pos, i, num; Suff *suff; - sd.len = strlen(gn->name); - sd.ename = eoname = gn->name + sd.len; + eoname = gn->name + strlen(gn->name); sopref = gn->name; @@ -2117,7 +2102,7 @@ SuffFindNormalDeps(GNode *gn, struct src for (pos = 0; pos < num; pos++) { suff = sufflist_get(&sufflist, pos); - if (SuffSuffIsSuffix(suff, &sd)) { + if (SuffSuffIsSuffix(suff, gn->name)) { /* * Next possible suffix...