Sat Oct 31 09:57:47 2020 UTC ()
make(1): fix indentation in source code


(rillig)
diff -r1.133 -r1.134 src/usr.bin/make/meta.c
diff -r1.613 -r1.614 src/usr.bin/make/var.c

cvs diff -r1.133 -r1.134 src/usr.bin/make/meta.c (expand / switch to unified diff)

--- src/usr.bin/make/meta.c 2020/10/30 20:30:44 1.133
+++ src/usr.bin/make/meta.c 2020/10/31 09:57:47 1.134
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: meta.c,v 1.133 2020/10/30 20:30:44 rillig Exp $ */ 1/* $NetBSD: meta.c,v 1.134 2020/10/31 09:57:47 rillig Exp $ */
2 2
3/* 3/*
4 * Implement 'meta' mode. 4 * Implement 'meta' mode.
5 * Adapted from John Birrell's patches to FreeBSD make. 5 * Adapted from John Birrell's patches to FreeBSD make.
6 * --sjg 6 * --sjg
7 */ 7 */
8/* 8/*
9 * Copyright (c) 2009-2016, Juniper Networks, Inc. 9 * Copyright (c) 2009-2016, Juniper Networks, Inc.
10 * Portions Copyright (c) 2009, John Birrell. 10 * Portions Copyright (c) 2009, John Birrell.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -316,27 +316,27 @@ meta_name(char *mname, size_t mnamelen, @@ -316,27 +316,27 @@ meta_name(char *mname, size_t mnamelen,
316static int 316static int
317is_submake(void *cmdp, void *gnp) 317is_submake(void *cmdp, void *gnp)
318{ 318{
319 static const char *p_make = NULL; 319 static const char *p_make = NULL;
320 static size_t p_len; 320 static size_t p_len;
321 char *cmd = cmdp; 321 char *cmd = cmdp;
322 GNode *gn = gnp; 322 GNode *gn = gnp;
323 char *mp = NULL; 323 char *mp = NULL;
324 char *cp; 324 char *cp;
325 char *cp2; 325 char *cp2;
326 int rc = 0; /* keep looking */ 326 int rc = 0; /* keep looking */
327 327
328 if (!p_make) { 328 if (!p_make) {
329 void *dontFreeIt; 329 void *dontFreeIt;
330 p_make = Var_Value(".MAKE", gn, &dontFreeIt); 330 p_make = Var_Value(".MAKE", gn, &dontFreeIt);
331 p_len = strlen(p_make); 331 p_len = strlen(p_make);
332 } 332 }
333 cp = strchr(cmd, '$'); 333 cp = strchr(cmd, '$');
334 if ((cp)) { 334 if ((cp)) {
335 (void)Var_Subst(cmd, gn, VARE_WANTRES, &mp); 335 (void)Var_Subst(cmd, gn, VARE_WANTRES, &mp);
336 /* TODO: handle errors */ 336 /* TODO: handle errors */
337 cmd = mp; 337 cmd = mp;
338 } 338 }
339 cp2 = strstr(cmd, p_make); 339 cp2 = strstr(cmd, p_make);
340 if ((cp2)) { 340 if ((cp2)) {
341 switch (cp2[p_len]) { 341 switch (cp2[p_len]) {
342 case '\0': 342 case '\0':
@@ -1592,27 +1592,27 @@ meta_oodate(GNode *gn, Boolean oodate) @@ -1592,27 +1592,27 @@ meta_oodate(GNode *gn, Boolean oodate)
1592 } 1592 }
1593 } 1593 }
1594 if (!cp) { 1594 if (!cp) {
1595 DEBUG1(META, "%s: required but missing\n", fname); 1595 DEBUG1(META, "%s: required but missing\n", fname);
1596 oodate = TRUE; 1596 oodate = TRUE;
1597 needOODATE = TRUE; /* assume the worst */ 1597 needOODATE = TRUE; /* assume the worst */
1598 } 1598 }
1599 } 1599 }
1600 } 1600 }
1601 1601
1602 Lst_Destroy(missingFiles, free); 1602 Lst_Destroy(missingFiles, free);
1603 1603
1604 if (oodate && needOODATE) { 1604 if (oodate && needOODATE) {
1605 void *freeIt; 1605 void *freeIt;
1606 /* 1606 /*
1607 * Target uses .OODATE which is empty; or we wouldn't be here. 1607 * Target uses .OODATE which is empty; or we wouldn't be here.
1608 * We have decided it is oodate, so .OODATE needs to be set. 1608 * We have decided it is oodate, so .OODATE needs to be set.
1609 * All we can sanely do is set it to .ALLSRC. 1609 * All we can sanely do is set it to .ALLSRC.
1610 */ 1610 */
1611 Var_Delete(OODATE, gn); 1611 Var_Delete(OODATE, gn);
1612 Var_Set(OODATE, Var_Value(ALLSRC, gn, &freeIt), gn); 1612 Var_Set(OODATE, Var_Value(ALLSRC, gn, &freeIt), gn);
1613 bmake_free(freeIt); 1613 bmake_free(freeIt);
1614 } 1614 }
1615 1615
1616 oodate_out: 1616 oodate_out:
1617 for (i--; i >= 0; i--) { 1617 for (i--; i >= 0; i--) {
1618 bmake_free(pa[i]); 1618 bmake_free(pa[i]);

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

--- src/usr.bin/make/var.c 2020/10/31 09:27:19 1.613
+++ src/usr.bin/make/var.c 2020/10/31 09:57:47 1.614
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: var.c,v 1.613 2020/10/31 09:27:19 rillig Exp $ */ 1/* $NetBSD: var.c,v 1.614 2020/10/31 09:57: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.
@@ -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.613 2020/10/31 09:27:19 rillig Exp $"); 132MAKE_RCSID("$NetBSD: var.c,v 1.614 2020/10/31 09:57:47 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 */
@@ -741,27 +741,27 @@ Var_UnExport(const char *str) @@ -741,27 +741,27 @@ Var_UnExport(const char *str)
741 VAR_DEBUG1("Unexporting \"%s\"\n", varname); 741 VAR_DEBUG1("Unexporting \"%s\"\n", varname);
742 if (!unexport_env && (v->flags & VAR_EXPORTED) && 742 if (!unexport_env && (v->flags & VAR_EXPORTED) &&
743 !(v->flags & VAR_REEXPORT)) 743 !(v->flags & VAR_REEXPORT))
744 unsetenv(v->name); 744 unsetenv(v->name);
745 v->flags &= ~(unsigned)(VAR_EXPORTED | VAR_REEXPORT); 745 v->flags &= ~(unsigned)(VAR_EXPORTED | VAR_REEXPORT);
746 746
747 /* 747 /*
748 * If we are unexporting a list, 748 * If we are unexporting a list,
749 * remove each one from .MAKE.EXPORTED. 749 * remove each one from .MAKE.EXPORTED.
750 * If we are removing them all, 750 * If we are removing them all,
751 * just delete .MAKE.EXPORTED below. 751 * just delete .MAKE.EXPORTED below.
752 */ 752 */
753 if (varnames == str) { 753 if (varnames == str) {
754 /* XXX: v->name is injected without escaping it */ 754 /* XXX: v->name is injected without escaping it */
755 char *expr = str_concat3("${" MAKE_EXPORTED ":N", v->name, "}"); 755 char *expr = str_concat3("${" MAKE_EXPORTED ":N", v->name, "}");
756 char *cp; 756 char *cp;
757 (void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &cp); 757 (void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &cp);
758 /* TODO: handle errors */ 758 /* TODO: handle errors */
759 Var_Set(MAKE_EXPORTED, cp, VAR_GLOBAL); 759 Var_Set(MAKE_EXPORTED, cp, VAR_GLOBAL);
760 free(cp); 760 free(cp);
761 free(expr); 761 free(expr);
762 } 762 }
763 } 763 }
764 Words_Free(words); 764 Words_Free(words);
765 if (varnames != str) { 765 if (varnames != str) {
766 Var_Delete(MAKE_EXPORTED, VAR_GLOBAL); 766 Var_Delete(MAKE_EXPORTED, VAR_GLOBAL);
767 free(varnames_freeIt); 767 free(varnames_freeIt);
@@ -937,27 +937,27 @@ Var_Append(const char *name, const char  @@ -937,27 +937,27 @@ Var_Append(const char *name, const char
937 "name expands to empty string - ignored\n", 937 "name expands to empty string - ignored\n",
938 unexpanded_name, val); 938 unexpanded_name, val);
939 free(name_freeIt); 939 free(name_freeIt);
940 return; 940 return;
941 } 941 }
942 } 942 }
943 943
944 v = VarFind(name, ctxt, ctxt == VAR_GLOBAL); 944 v = VarFind(name, ctxt, ctxt == VAR_GLOBAL);
945 945
946 if (v == NULL) { 946 if (v == NULL) {
947 /* XXX: name is expanded for the second time */ 947 /* XXX: name is expanded for the second time */
948 Var_Set(name, val, ctxt); 948 Var_Set(name, val, ctxt);
949 } else if (v->flags & VAR_READONLY) { 949 } else if (v->flags & VAR_READONLY) {
950 VAR_DEBUG1("Ignoring append to %s since it is read-only\n", name); 950 VAR_DEBUG1("Ignoring append to %s since it is read-only\n", name);
951 } else if (ctxt == VAR_CMDLINE || !(v->flags & VAR_FROM_CMD)) { 951 } else if (ctxt == VAR_CMDLINE || !(v->flags & VAR_FROM_CMD)) {
952 Buf_AddByte(&v->val, ' '); 952 Buf_AddByte(&v->val, ' ');
953 Buf_AddStr(&v->val, val); 953 Buf_AddStr(&v->val, val);
954 954
955 VAR_DEBUG3("%s:%s = %s\n", 955 VAR_DEBUG3("%s:%s = %s\n",
956 ctxt->name, name, Buf_GetAll(&v->val, NULL)); 956 ctxt->name, name, Buf_GetAll(&v->val, NULL));
957 957
958 if (v->flags & VAR_FROM_ENV) { 958 if (v->flags & VAR_FROM_ENV) {
959 HashEntry *h; 959 HashEntry *h;
960 960
961 /* 961 /*
962 * If the original variable came from the environment, we 962 * If the original variable came from the environment, we
963 * have to install it in the global context (we could place 963 * have to install it in the global context (we could place