Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make: make ModifyWord_Subst a little easier to ...



details:   https://anonhg.NetBSD.org/src/rev/7fa2346de498
branches:  trunk
changeset: 952984:7fa2346de498
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Feb 22 23:39:24 2021 +0000

description:
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.

diffstat:

 usr.bin/make/var.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (35 lines):

diff -r cf3c83986eb7 -r 7fa2346de498 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Feb 22 23:21:33 2021 +0000
+++ b/usr.bin/make/var.c        Mon Feb 22 23:39:24 2021 +0000
@@ -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 @@
                    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;
        }



Home | Main Index | Thread Index | Old Index