diff options
| author | rillig <rillig@NetBSD.org> | 2020-10-20 23:04:35 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2020-10-20 23:04:35 +0000 |
| commit | 1afebc773cefa8469c6f41639271daebba8b6dfd (patch) | |
| tree | 38767e0c49b29a859b57515f0e0201f8ccbc8177 /usr.bin/make/suff.c | |
| parent | a7c55392e68504c90757d55e56ae4da6e4783a6d (diff) | |
make(1): remove strange off-by-one feature in SuffSuffGetSuffix
The code worked as intended, yet it was strange to modify cp[1] to
temporarily shorten a string. Using cp[0] for this purpose is common
style.
Diffstat (limited to 'usr.bin/make/suff.c')
| -rw-r--r-- | usr.bin/make/suff.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 47c0b49ce45..2e42a365e75 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.198 2020/10/20 21:15:47 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.199 2020/10/20 23:04:35 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.198 2020/10/20 21:15:47 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.199 2020/10/20 23:04:35 rillig Exp $"); #define SUFF_DEBUG0(text) DEBUG0(SUFF, text) #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1) @@ -238,16 +238,14 @@ struct SuffSuffGetSuffixArgs { char *name_end; }; -/* See if suff is a suffix of str. str->ename should point to THE END - * of the string to check. (THE END == the null byte) +/* See if suff is a suffix of str. * * Input: * s possible suffix * str string to examine * * Results: - * NULL if it ain't, pointer to character in str before suffix if - * it is. + * NULL if it ain't, pointer to the start of suffix in str if it is. */ static char * SuffSuffGetSuffix(const Suff *s, const struct SuffSuffGetSuffixArgs *str) @@ -266,7 +264,7 @@ SuffSuffGetSuffix(const Suff *s, const struct SuffSuffGetSuffixArgs *str) p2--; } - return p1 == s->name - 1 ? p2 : NULL; + return p1 == s->name - 1 ? p2 + 1 : NULL; } /* Predicate form of SuffSuffGetSuffix, for Lst_Find. */ @@ -638,9 +636,9 @@ SuffRebuildGraph(GNode *transform, Suff *s) /* Null-terminate the source suffix in order to find it. */ /* XXX: don't modify strings, not even temporarily */ - cp[1] = '\0'; + cp[0] = '\0'; s2 = FindSuffByName(transform->name); - cp[1] = s->name[0]; /* restore */ + cp[0] = s->name[0]; /* restore */ if (s2 != NULL) { /* establish the proper relationship */ |
