Tue Sep 22 19:08:48 2020 UTC ()
make(1): remove obsolete fix for PR bin/29985


(rillig)
diff -r1.531 -r1.532 src/usr.bin/make/var.c
diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-for.exp
diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-for.mk

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

--- src/usr.bin/make/var.c 2020/09/22 18:07:58 1.531
+++ src/usr.bin/make/var.c 2020/09/22 19:08:47 1.532
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: var.c,v 1.531 2020/09/22 18:07:58 rillig Exp $ */ 1/* $NetBSD: var.c,v 1.532 2020/09/22 19:08:47 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.
@@ -111,27 +111,27 @@ @@ -111,27 +111,27 @@
111#include <sys/types.h> 111#include <sys/types.h>
112#include <regex.h> 112#include <regex.h>
113#endif 113#endif
114#include <inttypes.h> 114#include <inttypes.h>
115#include <limits.h> 115#include <limits.h>
116#include <time.h> 116#include <time.h>
117 117
118#include "make.h" 118#include "make.h"
119#include "dir.h" 119#include "dir.h"
120#include "job.h" 120#include "job.h"
121#include "metachar.h" 121#include "metachar.h"
122 122
123/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ 123/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
124MAKE_RCSID("$NetBSD: var.c,v 1.531 2020/09/22 18:07:58 rillig Exp $"); 124MAKE_RCSID("$NetBSD: var.c,v 1.532 2020/09/22 19:08:47 rillig Exp $");
125 125
126#define VAR_DEBUG_IF(cond, fmt, ...) \ 126#define VAR_DEBUG_IF(cond, fmt, ...) \
127 if (!(DEBUG(VAR) && (cond))) \ 127 if (!(DEBUG(VAR) && (cond))) \
128 (void) 0; \ 128 (void) 0; \
129 else \ 129 else \
130 fprintf(debug_file, fmt, __VA_ARGS__) 130 fprintf(debug_file, fmt, __VA_ARGS__)
131 131
132#define VAR_DEBUG(fmt, ...) VAR_DEBUG_IF(TRUE, fmt, __VA_ARGS__) 132#define VAR_DEBUG(fmt, ...) VAR_DEBUG_IF(TRUE, fmt, __VA_ARGS__)
133 133
134ENUM_FLAGS_RTTI_3(VarEvalFlags, 134ENUM_FLAGS_RTTI_3(VarEvalFlags,
135 VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN); 135 VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN);
136 136
137/* 137/*
@@ -3699,40 +3699,35 @@ Var_Parse(const char **pp, GNode *ctxt,  @@ -3699,40 +3699,35 @@ Var_Parse(const char **pp, GNode *ctxt,
3699 * str the string which to substitute 3699 * str the string which to substitute
3700 * ctxt the context wherein to find variables 3700 * ctxt the context wherein to find variables
3701 * eflags VARE_UNDEFERR if undefineds are an error 3701 * eflags VARE_UNDEFERR if undefineds are an error
3702 * VARE_WANTRES if we actually want the result 3702 * VARE_WANTRES if we actually want the result
3703 * VARE_ASSIGN if we are in a := assignment 3703 * VARE_ASSIGN if we are in a := assignment
3704 * 3704 *
3705 * Results: 3705 * Results:
3706 * The resulting string. 3706 * The resulting string.
3707 */ 3707 */
3708char * 3708char *
3709Var_Subst(const char *str, GNode *ctxt, VarEvalFlags eflags) 3709Var_Subst(const char *str, GNode *ctxt, VarEvalFlags eflags)
3710{ 3710{
3711 Buffer buf; /* Buffer for forming things */ 3711 Buffer buf; /* Buffer for forming things */
3712 Boolean trailingBackslash; 
3713 3712
3714 /* Set true if an error has already been reported, 3713 /* Set true if an error has already been reported,
3715 * to prevent a plethora of messages when recursing */ 3714 * to prevent a plethora of messages when recursing */
3716 static Boolean errorReported; 3715 static Boolean errorReported;
3717 3716
3718 Buf_Init(&buf, 0); 3717 Buf_Init(&buf, 0);
3719 errorReported = FALSE; 3718 errorReported = FALSE;
3720 trailingBackslash = FALSE; /* variable ends in \ */ 
3721 3719
3722 while (*str) { 3720 while (*str) {
3723 if (*str == '\n' && trailingBackslash) 
3724 Buf_AddByte(&buf, ' '); 
3725 
3726 if (*str == '$' && str[1] == '$') { 3721 if (*str == '$' && str[1] == '$') {
3727 /* 3722 /*
3728 * A dollar sign may be escaped with another dollar sign. 3723 * A dollar sign may be escaped with another dollar sign.
3729 * In such a case, we skip over the escape character and store the 3724 * In such a case, we skip over the escape character and store the
3730 * dollar sign into the buffer directly. 3725 * dollar sign into the buffer directly.
3731 */ 3726 */
3732 if (save_dollars && (eflags & VARE_ASSIGN)) 3727 if (save_dollars && (eflags & VARE_ASSIGN))
3733 Buf_AddByte(&buf, '$'); 3728 Buf_AddByte(&buf, '$');
3734 Buf_AddByte(&buf, '$'); 3729 Buf_AddByte(&buf, '$');
3735 str += 2; 3730 str += 2;
3736 } else if (*str != '$') { 3731 } else if (*str != '$') {
3737 /* 3732 /*
3738 * Skip as many characters as possible -- either to the end of 3733 * Skip as many characters as possible -- either to the end of
@@ -3772,27 +3767,26 @@ Var_Subst(const char *str, GNode *ctxt,  @@ -3772,27 +3767,26 @@ Var_Subst(const char *str, GNode *ctxt,
3772 str = nested_str; 3767 str = nested_str;
3773 errorReported = TRUE; 3768 errorReported = TRUE;
3774 } else { 3769 } else {
3775 Buf_AddByte(&buf, *str); 3770 Buf_AddByte(&buf, *str);
3776 str++; 3771 str++;
3777 } 3772 }
3778 } else { 3773 } else {
3779 size_t val_len; 3774 size_t val_len;
3780 3775
3781 str = nested_str; 3776 str = nested_str;
3782 3777
3783 val_len = strlen(val); 3778 val_len = strlen(val);
3784 Buf_AddBytes(&buf, val, val_len); 3779 Buf_AddBytes(&buf, val, val_len);
3785 trailingBackslash = val_len > 0 && val[val_len - 1] == '\\'; 
3786 } 3780 }
3787 free(freeIt); 3781 free(freeIt);
3788 freeIt = NULL; 3782 freeIt = NULL;
3789 } 3783 }
3790 } 3784 }
3791 3785
3792 return Buf_DestroyCompact(&buf); 3786 return Buf_DestroyCompact(&buf);
3793} 3787}
3794 3788
3795/* Initialize the module. */ 3789/* Initialize the module. */
3796void 3790void
3797Var_Init(void) 3791Var_Init(void)
3798{ 3792{

cvs diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-for.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/directive-for.exp 2020/09/22 18:54:50 1.3
+++ src/usr.bin/make/unit-tests/directive-for.exp 2020/09/22 19:08:48 1.4
@@ -1,3 +1,5 @@ @@ -1,3 +1,5 @@
1make: "directive-for.mk" line 100: outer 1make: "directive-for.mk" line 100: outer
2make: "directive-for.mk" line 125: a:\ a:\file.txt 2make: "directive-for.mk" line 125: a:\ a:\file.txt
 3make: "directive-for.mk" line 125: d:\\
 4make: "directive-for.mk" line 125: d:\\file.txt
3exit status 0 5exit status 0

cvs diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-for.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/directive-for.mk 2020/09/22 18:54:51 1.4
+++ src/usr.bin/make/unit-tests/directive-for.mk 2020/09/22 19:08:48 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: directive-for.mk,v 1.4 2020/09/22 18:54:51 rillig Exp $ 1# $NetBSD: directive-for.mk,v 1.5 2020/09/22 19:08:48 rillig Exp $
2# 2#
3# Tests for the .for directive. 3# Tests for the .for directive.
4 4
5# Using the .for loop, lists of values can be produced. 5# Using the .for loop, lists of values can be produced.
6# In simple cases, the :@var@${var}@ variable modifier can be used to 6# In simple cases, the :@var@${var}@ variable modifier can be used to
7# reach the same effects. 7# reach the same effects.
8# 8#
9.undef NUMBERS 9.undef NUMBERS
10.for num in 1 2 3 10.for num in 1 2 3
11NUMBERS+= ${num} 11NUMBERS+= ${num}
12.endfor 12.endfor
13.if ${NUMBERS} != "1 2 3" 13.if ${NUMBERS} != "1 2 3"
14. error 14. error
@@ -111,19 +111,19 @@ EXPANSION${plus}= value @@ -111,19 +111,19 @@ EXPANSION${plus}= value
111# Until 2012-06-03, the .for loop had split the words at whitespace, without 111# Until 2012-06-03, the .for loop had split the words at whitespace, without
112# taking quotes into account. This made it possible to have variable values 112# taking quotes into account. This made it possible to have variable values
113# like "a:\ a:\file.txt" that ended in a single backslash. Since then, the 113# like "a:\ a:\file.txt" that ended in a single backslash. Since then, the
114# variable values have been replaced with expressions of the form ${:U...}, 114# variable values have been replaced with expressions of the form ${:U...},
115# which are not interpreted as code anymore. 115# which are not interpreted as code anymore.
116# 116#
117# As of 2020-09-22, a comment in for.c says that it may be possible to 117# As of 2020-09-22, a comment in for.c says that it may be possible to
118# produce an "unwanted substitution", but there is no demonstration code yet. 118# produce an "unwanted substitution", but there is no demonstration code yet.
119# 119#
120# The above changes prevent a backslash at the end of a word from being 120# The above changes prevent a backslash at the end of a word from being
121# interpreted as part of the code. Because of this, the trailingBackslash 121# interpreted as part of the code. Because of this, the trailingBackslash
122# hack in Var_Subst is no longer needed and as of 2020-09-22, has been 122# hack in Var_Subst is no longer needed and as of 2020-09-22, has been
123# removed. 123# removed.
124.for path in a:\ a:\file.txt 124.for path in a:\ a:\file.txt d:\\ d:\\file.txt
125. info ${path} 125. info ${path}
126.endfor 126.endfor
127 127
128all: 128all:
129 @:; 129 @:;