Module Name: src Committed By: rillig Date: Sat Oct 31 08:40:54 UTC 2020
Modified Files: src/usr.bin/make: var.c Log Message: make(1): merge duplicate code in ModifyWord_Subst To generate a diff of this commit: cvs rdiff -u -r1.610 -r1.611 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.610 src/usr.bin/make/var.c:1.611 --- src/usr.bin/make/var.c:1.610 Fri Oct 30 22:55:34 2020 +++ src/usr.bin/make/var.c Sat Oct 31 08:40:54 2020 @@ -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 @@ ModifyWord_Subst(const char *word, SepBu 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; }