Sat Oct 31 18:14:59 2020 UTC ()
make(1): remove debug logging for the :Q variable modifier

The same information is already logged in LogAfterApply.


(rillig)
diff -r1.627 -r1.628 src/usr.bin/make/var.c
diff -r1.11 -r1.12 src/usr.bin/make/unit-tests/vardebug.exp

cvs diff -r1.627 -r1.628 src/usr.bin/make/var.c (expand / switch to unified diff)

--- src/usr.bin/make/var.c 2020/10/31 18:05:16 1.627
+++ src/usr.bin/make/var.c 2020/10/31 18:14:59 1.628
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: var.c,v 1.627 2020/10/31 18:05:16 rillig Exp $ */ 1/* $NetBSD: var.c,v 1.628 2020/10/31 18:14:59 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -119,27 +119,27 @@ @@ -119,27 +119,27 @@
119#include <sys/types.h> 119#include <sys/types.h>
120#include <regex.h> 120#include <regex.h>
121#endif 121#endif
122#include <inttypes.h> 122#include <inttypes.h>
123#include <limits.h> 123#include <limits.h>
124#include <time.h> 124#include <time.h>
125 125
126#include "make.h" 126#include "make.h"
127#include "dir.h" 127#include "dir.h"
128#include "job.h" 128#include "job.h"
129#include "metachar.h" 129#include "metachar.h"
130 130
131/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ 131/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
132MAKE_RCSID("$NetBSD: var.c,v 1.627 2020/10/31 18:05:16 rillig Exp $"); 132MAKE_RCSID("$NetBSD: var.c,v 1.628 2020/10/31 18:14:59 rillig Exp $");
133 133
134#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) 134#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
135#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) 135#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
136#define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3) 136#define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3)
137#define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4) 137#define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4)
138 138
139ENUM_FLAGS_RTTI_3(VarEvalFlags, 139ENUM_FLAGS_RTTI_3(VarEvalFlags,
140 VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN); 140 VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN);
141 141
142/* 142/*
143 * This lets us tell if we have replaced the original environ 143 * This lets us tell if we have replaced the original environ
144 * (which we cannot free). 144 * (which we cannot free).
145 */ 145 */
@@ -1626,48 +1626,45 @@ VarUniq(const char *str) @@ -1626,48 +1626,45 @@ VarUniq(const char *str)
1626 words.words[j] = words.words[i]; 1626 words.words[j] = words.words[i];
1627 words.len = j + 1; 1627 words.len = j + 1;
1628 } 1628 }
1629 1629
1630 return Words_JoinFree(words); 1630 return Words_JoinFree(words);
1631} 1631}
1632 1632
1633 1633
1634/* Quote shell meta-characters and space characters in the string. 1634/* Quote shell meta-characters and space characters in the string.
1635 * If quoteDollar is set, also quote and double any '$' characters. */ 1635 * If quoteDollar is set, also quote and double any '$' characters. */
1636static char * 1636static char *
1637VarQuote(const char *str, Boolean quoteDollar) 1637VarQuote(const char *str, Boolean quoteDollar)
1638{ 1638{
1639 char *res; 
1640 Buffer buf; 1639 Buffer buf;
1641 Buf_Init(&buf, 0); 1640 Buf_Init(&buf, 0);
1642 1641
1643 for (; *str != '\0'; str++) { 1642 for (; *str != '\0'; str++) {
1644 if (*str == '\n') { 1643 if (*str == '\n') {
1645 const char *newline = Shell_GetNewline(); 1644 const char *newline = Shell_GetNewline();
1646 if (newline == NULL) 1645 if (newline == NULL)
1647 newline = "\\\n"; 1646 newline = "\\\n";
1648 Buf_AddStr(&buf, newline); 1647 Buf_AddStr(&buf, newline);
1649 continue; 1648 continue;
1650 } 1649 }
1651 if (ch_isspace(*str) || ismeta((unsigned char)*str)) 1650 if (ch_isspace(*str) || ismeta((unsigned char)*str))
1652 Buf_AddByte(&buf, '\\'); 1651 Buf_AddByte(&buf, '\\');
1653 Buf_AddByte(&buf, *str); 1652 Buf_AddByte(&buf, *str);
1654 if (quoteDollar && *str == '$') 1653 if (quoteDollar && *str == '$')
1655 Buf_AddStr(&buf, "\\$"); 1654 Buf_AddStr(&buf, "\\$");
1656 } 1655 }
1657 1656
1658 res = Buf_Destroy(&buf, FALSE); 1657 return Buf_Destroy(&buf, FALSE);
1659 VAR_DEBUG1("QuoteMeta: [%s]\n", res); 
1660 return res; 
1661} 1658}
1662 1659
1663/* Compute the 32-bit hash of the given string, using the MurmurHash3 1660/* Compute the 32-bit hash of the given string, using the MurmurHash3
1664 * algorithm. Output is encoded as 8 hex digits, in Little Endian order. */ 1661 * algorithm. Output is encoded as 8 hex digits, in Little Endian order. */
1665static char * 1662static char *
1666VarHash(const char *str) 1663VarHash(const char *str)
1667{ 1664{
1668 static const char hexdigits[16] = "0123456789abcdef"; 1665 static const char hexdigits[16] = "0123456789abcdef";
1669 const unsigned char *ustr = (const unsigned char *)str; 1666 const unsigned char *ustr = (const unsigned char *)str;
1670 1667
1671 uint32_t h = 0x971e137bU; 1668 uint32_t h = 0x971e137bU;
1672 uint32_t c1 = 0x95543787U; 1669 uint32_t c1 = 0x95543787U;
1673 uint32_t c2 = 0x2ad7eb25U; 1670 uint32_t c2 = 0x2ad7eb25U;

cvs diff -r1.11 -r1.12 src/usr.bin/make/unit-tests/vardebug.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/vardebug.exp 2020/10/29 18:38:24 1.11
+++ src/usr.bin/make/unit-tests/vardebug.exp 2020/10/31 18:14:59 1.12
@@ -28,35 +28,33 @@ Result of ${VAR:M[2]} is "2" (VARE_UNDEF @@ -28,35 +28,33 @@ Result of ${VAR:M[2]} is "2" (VARE_UNDEF
28Var_Parse: ${VAR:N[2]} with VARE_UNDEFERR|VARE_WANTRES 28Var_Parse: ${VAR:N[2]} with VARE_UNDEFERR|VARE_WANTRES
29Applying ${VAR:N...} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 29Applying ${VAR:N...} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
30Pattern[VAR] for [1 2 3] is [[2]] 30Pattern[VAR] for [1 2 3] is [[2]]
31ModifyWords: split "1 2 3" into 3 words 31ModifyWords: split "1 2 3" into 3 words
32Result of ${VAR:N[2]} is "1 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 32Result of ${VAR:N[2]} is "1 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
33Var_Parse: ${VAR:S,2,two,} with VARE_UNDEFERR|VARE_WANTRES 33Var_Parse: ${VAR:S,2,two,} with VARE_UNDEFERR|VARE_WANTRES
34Applying ${VAR:S...} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 34Applying ${VAR:S...} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
35Modifier part: "2" 35Modifier part: "2"
36Modifier part: "two" 36Modifier part: "two"
37ModifyWords: split "1 2 3" into 3 words 37ModifyWords: split "1 2 3" into 3 words
38Result of ${VAR:S,2,two,} is "1 two 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 38Result of ${VAR:S,2,two,} is "1 two 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
39Var_Parse: ${VAR:Q} with VARE_UNDEFERR|VARE_WANTRES 39Var_Parse: ${VAR:Q} with VARE_UNDEFERR|VARE_WANTRES
40Applying ${VAR:Q} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 40Applying ${VAR:Q} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
41QuoteMeta: [1\ 2\ 3] 
42Result of ${VAR:Q} is "1\ 2\ 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 41Result of ${VAR:Q} is "1\ 2\ 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
43Var_Parse: ${VAR:tu:tl:Q} with VARE_UNDEFERR|VARE_WANTRES 42Var_Parse: ${VAR:tu:tl:Q} with VARE_UNDEFERR|VARE_WANTRES
44Applying ${VAR:t...} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 43Applying ${VAR:t...} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
45Result of ${VAR:tu} is "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 44Result of ${VAR:tu} is "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
46Applying ${VAR:t...} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 45Applying ${VAR:t...} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
47Result of ${VAR:tl} is "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 46Result of ${VAR:tl} is "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
48Applying ${VAR:Q} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 47Applying ${VAR:Q} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
49QuoteMeta: [1\ 2\ 3] 
50Result of ${VAR:Q} is "1\ 2\ 3" (VARE_UNDEFERR|VARE_WANTRES, none, none) 48Result of ${VAR:Q} is "1\ 2\ 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
51Var_Parse: ${:Uvalue:${:UM*e}:Mvalu[e]} with VARE_UNDEFERR|VARE_WANTRES 49Var_Parse: ${:Uvalue:${:UM*e}:Mvalu[e]} with VARE_UNDEFERR|VARE_WANTRES
52Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF) 50Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
53Result of ${:Uvalue} is "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF) 51Result of ${:Uvalue} is "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
54Var_Parse: ${:UM*e}:Mvalu[e]} with VARE_UNDEFERR|VARE_WANTRES 52Var_Parse: ${:UM*e}:Mvalu[e]} with VARE_UNDEFERR|VARE_WANTRES
55Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF) 53Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
56Result of ${:UM*e} is "M*e" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF) 54Result of ${:UM*e} is "M*e" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
57Indirect modifier "M*e" from "${:UM*e}" 55Indirect modifier "M*e" from "${:UM*e}"
58Applying ${:M...} to "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF) 56Applying ${:M...} to "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
59Pattern[] for [value] is [*e] 57Pattern[] for [value] is [*e]
60ModifyWords: split "value" into 1 words 58ModifyWords: split "value" into 1 words
61VarMatch [value] [*e] 59VarMatch [value] [*e]
62Result of ${:M*e} is "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF) 60Result of ${:M*e} is "value" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)