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(1): merge duplicate code in ModifyWord_Subst



details:   https://anonhg.NetBSD.org/src/rev/5eed9c6d6f3c
branches:  trunk
changeset: 977684:5eed9c6d6f3c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 31 08:40:54 2020 +0000

description:
make(1): merge duplicate code in ModifyWord_Subst

diffstat:

 usr.bin/make/var.c |  24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diffs (45 lines):

diff -r 839708368a12 -r 5eed9c6d6f3c usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Oct 31 08:31:37 2020 +0000
+++ b/usr.bin/make/var.c        Sat Oct 31 08:40:54 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.610 2020/10/30 22:55:34 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.611 2020/10/31 08:40:54 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include    "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.610 2020/10/30 22:55:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.611 2020/10/31 08:40:54 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1294,19 +1294,13 @@
            memcmp(word, args->lhs, args->lhsLen) != 0)
            goto nosub;
 
-       if (args->pflags & VARP_ANCHOR_END) {
-           if (wordLen != args->lhsLen)
-               goto nosub;
-
-           /* :S,^whole$,replacement, */
-           SepBuf_AddBytes(buf, args->rhs, args->rhsLen);
-           args->matched = TRUE;
-       } else {
-           /* :S,^prefix,replacement, */
-           SepBuf_AddBytes(buf, args->rhs, args->rhsLen);
-           SepBuf_AddBytes(buf, word + args->lhsLen, wordLen - args->lhsLen);
-           args->matched = TRUE;
-       }
+       if ((args->pflags & VARP_ANCHOR_END) && 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);
+       args->matched = TRUE;
        return;
     }
 



Home | Main Index | Thread Index | Old Index