Module Name: src
Committed By: rillig
Date: Mon Feb 22 23:39:24 UTC 2021
Modified Files:
src/usr.bin/make: var.c
Log Message:
make: make ModifyWord_Subst a little easier to understand
Addition is easier than subtraction, and the expression 'word + wordLen'
obviously means 'the end of the word', which was not as easy to spot
before.
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.838 -r1.839 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.838 src/usr.bin/make/var.c:1.839
--- src/usr.bin/make/var.c:1.838 Mon Feb 22 23:21:33 2021
+++ src/usr.bin/make/var.c Mon Feb 22 23:39:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.838 2021/02/22 23:21:33 rillig Exp $ */
+/* $NetBSD: var.c,v 1.839 2021/02/22 23:39:24 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.838 2021/02/22 23:21:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.839 2021/02/22 23:39:24 rillig Exp $");
typedef enum VarFlags {
VFL_NONE = 0,
@@ -1541,13 +1541,13 @@ ModifyWord_Subst(const char *word, SepBu
memcmp(word, args->lhs, args->lhsLen) != 0)
goto nosub;
- if ((args->pflags.anchorEnd) && wordLen != args->lhsLen)
+ if (args->pflags.anchorEnd && wordLen != args->lhsLen)
goto nosub;
/* :S,^prefix,replacement, or :S,^whole$,replacement, */
SepBuf_AddBytes(buf, args->rhs, args->rhsLen);
- SepBuf_AddBytes(buf, word + args->lhsLen,
- wordLen - args->lhsLen);
+ SepBuf_AddBytesBetween(buf,
+ word + args->lhsLen, word + wordLen);
args->matched = TRUE;
return;
}