Sun Mar 14 15:19:15 2021 UTC ()
make: separate parsing and evaluating for modifiers ':Q' and ':q'

No functional change.


(rillig)
diff -r1.860 -r1.861 src/usr.bin/make/var.c

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

--- src/usr.bin/make/var.c 2021/03/14 15:15:28 1.860
+++ src/usr.bin/make/var.c 2021/03/14 15:19:15 1.861
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: var.c,v 1.860 2021/03/14 15:15:28 rillig Exp $ */ 1/* $NetBSD: var.c,v 1.861 2021/03/14 15:19:15 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.
@@ -130,27 +130,27 @@ @@ -130,27 +130,27 @@
130#include <regex.h> 130#include <regex.h>
131#endif 131#endif
132#include <errno.h> 132#include <errno.h>
133#include <inttypes.h> 133#include <inttypes.h>
134#include <limits.h> 134#include <limits.h>
135#include <time.h> 135#include <time.h>
136 136
137#include "make.h" 137#include "make.h"
138#include "dir.h" 138#include "dir.h"
139#include "job.h" 139#include "job.h"
140#include "metachar.h" 140#include "metachar.h"
141 141
142/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ 142/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
143MAKE_RCSID("$NetBSD: var.c,v 1.860 2021/03/14 15:15:28 rillig Exp $"); 143MAKE_RCSID("$NetBSD: var.c,v 1.861 2021/03/14 15:19:15 rillig Exp $");
144 144
145typedef enum VarFlags { 145typedef enum VarFlags {
146 VFL_NONE = 0, 146 VFL_NONE = 0,
147 147
148 /* 148 /*
149 * The variable's value is currently being used by Var_Parse or 149 * The variable's value is currently being used by Var_Parse or
150 * Var_Subst. This marker is used to avoid endless recursion. 150 * Var_Subst. This marker is used to avoid endless recursion.
151 */ 151 */
152 VFL_IN_USE = 1 << 0, 152 VFL_IN_USE = 1 << 0,
153 153
154 /* 154 /*
155 * The variable comes from the environment. 155 * The variable comes from the environment.
156 * These variables are not registered in any GNode, therefore they 156 * These variables are not registered in any GNode, therefore they
@@ -2914,33 +2914,34 @@ ApplyModifier_Regex(const char **pp, App @@ -2914,33 +2914,34 @@ ApplyModifier_Regex(const char **pp, App
2914 ModifyWords(st, ModifyWord_SubstRegex, &args, oneBigWord); 2914 ModifyWords(st, ModifyWord_SubstRegex, &args, oneBigWord);
2915 2915
2916 regfree(&args.re); 2916 regfree(&args.re);
2917 free(args.replace); 2917 free(args.replace);
2918 return AMR_OK; 2918 return AMR_OK;
2919} 2919}
2920 2920
2921#endif 2921#endif
2922 2922
2923/* :Q, :q */ 2923/* :Q, :q */
2924static ApplyModifierResult 2924static ApplyModifierResult
2925ApplyModifier_Quote(const char **pp, ApplyModifiersState *st) 2925ApplyModifier_Quote(const char **pp, ApplyModifiersState *st)
2926{ 2926{
2927 if (IsDelimiter((*pp)[1], st)) { 2927 Boolean quoteDollar = **pp == 'q';
2928 Expr_SetValueOwn(st->expr, 2928 if (!IsDelimiter((*pp)[1], st))
2929 VarQuote(st->expr->value.str, **pp == 'q')); 
2930 (*pp)++; 
2931 return AMR_OK; 
2932 } else 
2933 return AMR_UNKNOWN; 2929 return AMR_UNKNOWN;
 2930 (*pp)++;
 2931
 2932 Expr_SetValueOwn(st->expr, VarQuote(st->expr->value.str, quoteDollar));
 2933
 2934 return AMR_OK;
2934} 2935}
2935 2936
2936/*ARGSUSED*/ 2937/*ARGSUSED*/
2937static void 2938static void
2938ModifyWord_Copy(const char *word, SepBuf *buf, void *data MAKE_ATTR_UNUSED) 2939ModifyWord_Copy(const char *word, SepBuf *buf, void *data MAKE_ATTR_UNUSED)
2939{ 2940{
2940 SepBuf_AddStr(buf, word); 2941 SepBuf_AddStr(buf, word);
2941} 2942}
2942 2943
2943/* :ts<separator> */ 2944/* :ts<separator> */
2944static ApplyModifierResult 2945static ApplyModifierResult
2945ApplyModifier_ToSep(const char **pp, ApplyModifiersState *st) 2946ApplyModifier_ToSep(const char **pp, ApplyModifiersState *st)
2946{ 2947{