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): add missing test for the :H and :T mod...



details:   https://anonhg.NetBSD.org/src/rev/46efc994a907
branches:  trunk
changeset: 973523:46efc994a907
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jul 03 14:59:17 2020 +0000

description:
make(1): add missing test for the :H and :T modifiers

diffstat:

 usr.bin/make/unit-tests/modmisc.exp |   4 ++++
 usr.bin/make/unit-tests/modmisc.mk  |  10 ++++++++--
 usr.bin/make/var.c                  |  10 ++++------
 3 files changed, 16 insertions(+), 8 deletions(-)

diffs (77 lines):

diff -r 75c06353063a -r 46efc994a907 usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp       Fri Jul 03 14:14:04 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp       Fri Jul 03 14:59:17 2020 +0000
@@ -7,4 +7,8 @@
 paths=/bin /tmp / /no/such/dir /opt/xbin
 PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN
 The answer is 42
+head of a/b/c is a/b
+tail of a/b/c is c
+head of abc is .
+tail of abc is abc
 exit status 0
diff -r 75c06353063a -r 46efc994a907 usr.bin/make/unit-tests/modmisc.mk
--- a/usr.bin/make/unit-tests/modmisc.mk        Fri Jul 03 14:14:04 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.mk        Fri Jul 03 14:59:17 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.1 2014/08/21 13:44:51 apb Exp $
+# $Id: modmisc.mk,v 1.2 2020/07/03 14:59:17 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -15,7 +15,7 @@
 MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@
 MOD_SEP=S,:, ,g
 
-all:   modvar modvarloop modsysv
+all:   modvar modvarloop modsysv modhead
 
 modsysv:
        @echo "The answer is ${libfoo.a:L:libfoo.a=42}"
@@ -36,3 +36,9 @@
        @echo "path_/usr/xbin=${path_/usr/xbin}"
        @echo "paths=${paths}"
        @echo "PATHS=${paths:tu}"
+
+modhead:
+       @echo "head of a/b/c is ${a/b/c:L:H}"
+       @echo "tail of a/b/c is ${a/b/c:L:T}"
+       @echo "head of abc is ${abc:L:H}"
+       @echo "tail of abc is ${abc:L:T}"
diff -r 75c06353063a -r 46efc994a907 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Fri Jul 03 14:14:04 2020 +0000
+++ b/usr.bin/make/var.c        Fri Jul 03 14:59:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.236 2020/07/03 14:14:04 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.237 2020/07/03 14:59:17 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.236 2020/07/03 14:14:04 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.237 2020/07/03 14:59:17 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.236 2020/07/03 14:14:04 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.237 2020/07/03 14:59:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1202,9 +1202,7 @@
        if (addSpace && vpstate->varSpace) {
            Buf_AddByte(buf, vpstate->varSpace);
        }
-       *slash = '\0';
-       Buf_AddBytes(buf, strlen(word), word);
-       *slash = '/';
+       Buf_AddBytes(buf, slash - word, word);
        return TRUE;
     } else {
        /*



Home | Main Index | Thread Index | Old Index