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): indent remaining code of var.c with ta...
details: https://anonhg.NetBSD.org/src/rev/3d7bbcd04d45
branches: trunk
changeset: 978818:3d7bbcd04d45
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Dec 05 14:55:17 2020 +0000
description:
make(1): indent remaining code of var.c with tabs instead of spaces
diffstat:
usr.bin/make/var.c | 603 +++++++++++++++++++++++++++-------------------------
1 files changed, 308 insertions(+), 295 deletions(-)
diffs (truncated from 663 to 300 lines):
diff -r 392fa03559d0 -r 3d7bbcd04d45 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sat Dec 05 14:50:33 2020 +0000
+++ b/usr.bin/make/var.c Sat Dec 05 14:55:17 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.703 2020/12/05 14:28:09 rillig Exp $ */
+/* $NetBSD: var.c,v 1.704 2020/12/05 14:55:17 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.703 2020/12/05 14:28:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.704 2020/12/05 14:55:17 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -800,96 +800,97 @@
Var_SetWithFlags(const char *name, const char *val, GNode *ctxt,
VarSetFlags flags)
{
- const char *unexpanded_name = name;
- char *name_freeIt = NULL;
- Var *v;
-
- assert(val != NULL);
-
- if (strchr(name, '$') != NULL) {
- (void)Var_Subst(name, ctxt, VARE_WANTRES, &name_freeIt);
- /* TODO: handle errors */
- name = name_freeIt;
- }
-
- if (name[0] == '\0') {
- VAR_DEBUG2("Var_Set(\"%s\", \"%s\", ...) "
- "name expands to empty string - ignored\n",
- unexpanded_name, val);
- free(name_freeIt);
- return;
- }
-
- if (ctxt == VAR_GLOBAL) {
- v = VarFind(name, VAR_CMDLINE, FALSE);
- if (v != NULL) {
- if (v->flags & VAR_FROM_CMD) {
- VAR_DEBUG3("%s:%s = %s ignored!\n", ctxt->name, name, val);
- goto out;
- }
- VarFreeEnv(v, TRUE);
+ const char *unexpanded_name = name;
+ char *name_freeIt = NULL;
+ Var *v;
+
+ assert(val != NULL);
+
+ if (strchr(name, '$') != NULL) {
+ (void)Var_Subst(name, ctxt, VARE_WANTRES, &name_freeIt);
+ /* TODO: handle errors */
+ name = name_freeIt;
}
- }
-
- /*
- * We only look for a variable in the given context since anything set
- * here will override anything in a lower context, so there's not much
- * point in searching them all just to save a bit of memory...
- */
- v = VarFind(name, ctxt, FALSE);
- if (v == NULL) {
- if (ctxt == VAR_CMDLINE && !(flags & VAR_SET_NO_EXPORT)) {
- /*
- * This var would normally prevent the same name being added
- * to VAR_GLOBAL, so delete it from there if needed.
- * Otherwise -V name may show the wrong value.
- */
- /* XXX: name is expanded for the second time */
- Var_Delete(name, VAR_GLOBAL);
+
+ if (name[0] == '\0') {
+ VAR_DEBUG2("Var_Set(\"%s\", \"%s\", ...) "
+ "name expands to empty string - ignored\n",
+ unexpanded_name, val);
+ free(name_freeIt);
+ return;
}
- VarAdd(name, val, ctxt, flags);
- } else {
- if ((v->flags & VAR_READONLY) && !(flags & VAR_SET_READONLY)) {
- VAR_DEBUG3("%s:%s = %s ignored (read-only)\n",
- ctxt->name, name, val);
- goto out;
+
+ if (ctxt == VAR_GLOBAL) {
+ v = VarFind(name, VAR_CMDLINE, FALSE);
+ if (v != NULL) {
+ if (v->flags & VAR_FROM_CMD) {
+ VAR_DEBUG3("%s:%s = %s ignored!\n",
+ ctxt->name, name, val);
+ goto out;
+ }
+ VarFreeEnv(v, TRUE);
+ }
}
- Buf_Empty(&v->val);
- Buf_AddStr(&v->val, val);
-
- VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val);
- if (v->flags & VAR_EXPORTED) {
- Var_Export1(name, VAR_EXPORT_PARENT);
- }
- }
- /*
- * Any variables given on the command line are automatically exported
- * to the environment (as per POSIX standard)
- * Other than internals.
- */
- if (ctxt == VAR_CMDLINE && !(flags & VAR_SET_NO_EXPORT) && name[0] != '.') {
- if (v == NULL)
- v = VarFind(name, ctxt, FALSE); /* we just added it */
- v->flags |= VAR_FROM_CMD;
/*
- * If requested, don't export these in the environment
- * individually. We still put them in MAKEOVERRIDES so
- * that the command-line settings continue to override
- * Makefile settings.
+ * We only look for a variable in the given context since anything set
+ * here will override anything in a lower context, so there's not much
+ * point in searching them all just to save a bit of memory...
*/
- if (!opts.varNoExportEnv)
- setenv(name, val, 1);
-
- Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
- }
- if (name[0] == '.' && strcmp(name, MAKE_SAVE_DOLLARS) == 0)
- save_dollars = ParseBoolean(val, save_dollars);
+ v = VarFind(name, ctxt, FALSE);
+ if (v == NULL) {
+ if (ctxt == VAR_CMDLINE && !(flags & VAR_SET_NO_EXPORT)) {
+ /*
+ * This var would normally prevent the same name being
+ * added to VAR_GLOBAL, so delete it from there if
+ * needed. Otherwise -V name may show the wrong value.
+ */
+ /* XXX: name is expanded for the second time */
+ Var_Delete(name, VAR_GLOBAL);
+ }
+ VarAdd(name, val, ctxt, flags);
+ } else {
+ if ((v->flags & VAR_READONLY) && !(flags & VAR_SET_READONLY)) {
+ VAR_DEBUG3("%s:%s = %s ignored (read-only)\n",
+ ctxt->name, name, val);
+ goto out;
+ }
+ Buf_Empty(&v->val);
+ Buf_AddStr(&v->val, val);
+
+ VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val);
+ if (v->flags & VAR_EXPORTED)
+ Var_Export1(name, VAR_EXPORT_PARENT);
+ }
+ /*
+ * Any variables given on the command line are automatically exported
+ * to the environment (as per POSIX standard)
+ * Other than internals.
+ */
+ if (ctxt == VAR_CMDLINE && !(flags & VAR_SET_NO_EXPORT) &&
+ name[0] != '.') {
+ if (v == NULL)
+ v = VarFind(name, ctxt, FALSE); /* we just added it */
+ v->flags |= VAR_FROM_CMD;
+
+ /*
+ * If requested, don't export these in the environment
+ * individually. We still put them in MAKEOVERRIDES so
+ * that the command-line settings continue to override
+ * Makefile settings.
+ */
+ if (!opts.varNoExportEnv)
+ setenv(name, val, 1);
+
+ Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
+ }
+ if (name[0] == '.' && strcmp(name, MAKE_SAVE_DOLLARS) == 0)
+ save_dollars = ParseBoolean(val, save_dollars);
out:
- free(name_freeIt);
- if (v != NULL)
- VarFreeEnv(v, TRUE);
+ free(name_freeIt);
+ if (v != NULL)
+ VarFreeEnv(v, TRUE);
}
/*-
@@ -948,53 +949,57 @@
void
Var_Append(const char *name, const char *val, GNode *ctxt)
{
- char *name_freeIt = NULL;
- Var *v;
-
- assert(val != NULL);
-
- if (strchr(name, '$') != NULL) {
- const char *unexpanded_name = name;
- (void)Var_Subst(name, ctxt, VARE_WANTRES, &name_freeIt);
- /* TODO: handle errors */
- name = name_freeIt;
- if (name[0] == '\0') {
- VAR_DEBUG2("Var_Append(\"%s\", \"%s\", ...) "
- "name expands to empty string - ignored\n",
- unexpanded_name, val);
- free(name_freeIt);
- return;
+ char *name_freeIt = NULL;
+ Var *v;
+
+ assert(val != NULL);
+
+ if (strchr(name, '$') != NULL) {
+ const char *unexpanded_name = name;
+ (void)Var_Subst(name, ctxt, VARE_WANTRES, &name_freeIt);
+ /* TODO: handle errors */
+ name = name_freeIt;
+ if (name[0] == '\0') {
+ VAR_DEBUG2("Var_Append(\"%s\", \"%s\", ...) "
+ "name expands to empty string - ignored\n",
+ unexpanded_name, val);
+ free(name_freeIt);
+ return;
+ }
}
- }
-
- v = VarFind(name, ctxt, ctxt == VAR_GLOBAL);
-
- if (v == NULL) {
- /* XXX: name is expanded for the second time */
- Var_Set(name, val, ctxt);
- } else if (v->flags & VAR_READONLY) {
- VAR_DEBUG1("Ignoring append to %s since it is read-only\n", name);
- } else if (ctxt == VAR_CMDLINE || !(v->flags & VAR_FROM_CMD)) {
- Buf_AddByte(&v->val, ' ');
- Buf_AddStr(&v->val, val);
-
- VAR_DEBUG3("%s:%s = %s\n",
- ctxt->name, name, Buf_GetAll(&v->val, NULL));
-
- if (v->flags & VAR_FROM_ENV) {
- /*
- * If the original variable came from the environment, we
- * have to install it in the global context (we could place
- * it in the environment, but then we should provide a way to
- * export other variables...)
- */
- v->flags &= ~(unsigned)VAR_FROM_ENV;
- /* This is the only place where a variable is created whose
- * v->name is not the same as ctxt->context->key. */
- HashTable_Set(&ctxt->vars, name, v);
+
+ v = VarFind(name, ctxt, ctxt == VAR_GLOBAL);
+
+ if (v == NULL) {
+ /* XXX: name is expanded for the second time */
+ Var_Set(name, val, ctxt);
+ } else if (v->flags & VAR_READONLY) {
+ VAR_DEBUG1("Ignoring append to %s since it is read-only\n",
+ name);
+ } else if (ctxt == VAR_CMDLINE || !(v->flags & VAR_FROM_CMD)) {
+ Buf_AddByte(&v->val, ' ');
+ Buf_AddStr(&v->val, val);
+
+ VAR_DEBUG3("%s:%s = %s\n",
+ ctxt->name, name, Buf_GetAll(&v->val, NULL));
+
+ if (v->flags & VAR_FROM_ENV) {
+ /*
+ * If the original variable came from the environment,
+ * we have to install it in the global context (we
+ * could place it in the environment, but then we
+ * should provide a way to export other variables...)
+ */
+ v->flags &= ~(unsigned)VAR_FROM_ENV;
+ /*
+ * This is the only place where a variable is
+ * created whose v->name is not the same as
+ * ctxt->context->key.
+ */
+ HashTable_Set(&ctxt->vars, name, v);
+ }
}
- }
- free(name_freeIt);
+ free(name_freeIt);
}
Home |
Main Index |
Thread Index |
Old Index