Sun Dec 27 18:22:28 2020 UTC ()
make(1): skip variable expansion in ParseDependencyTargetWord

The goal of the code is just to skip over the variable expression, thus
there is no need to evaluate it.


(rillig)
diff -r1.518 -r1.519 src/usr.bin/make/parse.c

cvs diff -r1.518 -r1.519 src/usr.bin/make/parse.c (expand / switch to unified diff)

--- src/usr.bin/make/parse.c 2020/12/27 11:47:04 1.518
+++ src/usr.bin/make/parse.c 2020/12/27 18:22:28 1.519
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: parse.c,v 1.518 2020/12/27 11:47:04 rillig Exp $ */ 1/* $NetBSD: parse.c,v 1.519 2020/12/27 18:22:28 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.
@@ -107,27 +107,27 @@ @@ -107,27 +107,27 @@
107#ifndef MAP_FILE 107#ifndef MAP_FILE
108#define MAP_FILE 0 108#define MAP_FILE 0
109#endif 109#endif
110#ifndef MAP_COPY 110#ifndef MAP_COPY
111#define MAP_COPY MAP_PRIVATE 111#define MAP_COPY MAP_PRIVATE
112#endif 112#endif
113 113
114#include "make.h" 114#include "make.h"
115#include "dir.h" 115#include "dir.h"
116#include "job.h" 116#include "job.h"
117#include "pathnames.h" 117#include "pathnames.h"
118 118
119/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ 119/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
120MAKE_RCSID("$NetBSD: parse.c,v 1.518 2020/12/27 11:47:04 rillig Exp $"); 120MAKE_RCSID("$NetBSD: parse.c,v 1.519 2020/12/27 18:22:28 rillig Exp $");
121 121
122/* types and constants */ 122/* types and constants */
123 123
124/* 124/*
125 * Structure for a file being read ("included file") 125 * Structure for a file being read ("included file")
126 */ 126 */
127typedef struct IFile { 127typedef struct IFile {
128 char *fname; /* name of file (relative? absolute?) */ 128 char *fname; /* name of file (relative? absolute?) */
129 Boolean fromForLoop; /* simulated .include by the .for loop */ 129 Boolean fromForLoop; /* simulated .include by the .for loop */
130 int lineno; /* current line number in file */ 130 int lineno; /* current line number in file */
131 int first_lineno; /* line number of start of text */ 131 int first_lineno; /* line number of start of text */
132 unsigned int cond_depth; /* 'if' nesting when file opened */ 132 unsigned int cond_depth; /* 'if' nesting when file opened */
133 Boolean depending; /* state of doing_depend on EOF */ 133 Boolean depending; /* state of doing_depend on EOF */
@@ -1074,29 +1074,28 @@ ParseDependencyTargetWord(const char **p @@ -1074,29 +1074,28 @@ ParseDependencyTargetWord(const char **p
1074 if (*cp == '$') { 1074 if (*cp == '$') {
1075 /* 1075 /*
1076 * Must be a dynamic source (would have been expanded 1076 * Must be a dynamic source (would have been expanded
1077 * otherwise), so call the Var module to parse the 1077 * otherwise), so call the Var module to parse the
1078 * puppy so we can safely advance beyond it. 1078 * puppy so we can safely advance beyond it.
1079 * 1079 *
1080 * There should be no errors in this, as they would 1080 * There should be no errors in this, as they would
1081 * have been discovered in the initial Var_Subst and 1081 * have been discovered in the initial Var_Subst and
1082 * we wouldn't be here. 1082 * we wouldn't be here.
1083 */ 1083 */
1084 const char *nested_p = cp; 1084 const char *nested_p = cp;
1085 FStr nested_val; 1085 FStr nested_val;
1086 1086
1087 /* XXX: Why VARE_WANTRES? */ 1087 (void)Var_Parse(&nested_p, VAR_CMDLINE, VARE_NONE,
1088 (void)Var_Parse(&nested_p, VAR_CMDLINE, 1088 &nested_val);
1089 VARE_WANTRES | VARE_UNDEFERR, &nested_val); 
1090 /* TODO: handle errors */ 1089 /* TODO: handle errors */
1091 FStr_Done(&nested_val); 1090 FStr_Done(&nested_val);
1092 cp += nested_p - cp; 1091 cp += nested_p - cp;
1093 } else 1092 } else
1094 cp++; 1093 cp++;
1095 } 1094 }
1096 1095
1097 *pp = cp; 1096 *pp = cp;
1098} 1097}
1099 1098
1100/* Handle special targets like .PATH, .DEFAULT, .BEGIN, .ORDER. */ 1099/* Handle special targets like .PATH, .DEFAULT, .BEGIN, .ORDER. */
1101static void 1100static void
1102ParseDoDependencyTargetSpecial(ParseSpecial *inout_specType, 1101ParseDoDependencyTargetSpecial(ParseSpecial *inout_specType,