Module Name: src Committed By: rillig Date: Sat Sep 24 10:26:32 UTC 2022
Modified Files: src/usr.bin/make: cond.c make.h parse.c Log Message: make: fix variable and function names relating to .if nesting The previous names were confusing since they suggested that cond_depth instead of cond_min_depth would be saved and restored. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.340 -r1.341 src/usr.bin/make/cond.c cvs rdiff -u -r1.305 -r1.306 src/usr.bin/make/make.h cvs rdiff -u -r1.684 -r1.685 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.340 src/usr.bin/make/cond.c:1.341 --- src/usr.bin/make/cond.c:1.340 Sat Sep 24 10:19:07 2022 +++ src/usr.bin/make/cond.c Sat Sep 24 10:26:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.340 2022/09/24 10:19:07 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.341 2022/09/24 10:26:31 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -81,8 +81,9 @@ * of one of the .if directives or the condition in a * ':?then:else' variable modifier. * - * Cond_save_depth - * Cond_restore_depth + * Cond_PushMinDepth + * Cond_PopMinDepth + * Cond_ResetDepth * Save and restore the nesting of the conditions, at * the start and end of including another makefile, to * ensure that in each makefile the conditional @@ -95,7 +96,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.340 2022/09/24 10:19:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.341 2022/09/24 10:26:31 rillig Exp $"); /* * Conditional expressions conform to this grammar: @@ -1256,7 +1257,7 @@ Cond_EvalLine(const char *line) } unsigned int -Cond_save_depth(void) +Cond_PushMinDepth(void) { unsigned int depth = cond_min_depth; @@ -1265,7 +1266,7 @@ Cond_save_depth(void) } void -Cond_restore_depth(unsigned int saved_depth) +Cond_PopMinDepth(unsigned int saved_depth) { unsigned int open_conds = cond_depth - cond_min_depth; @@ -1280,12 +1281,11 @@ Cond_restore_depth(unsigned int saved_de } /* - * When we break out of a .for loop - * we want to restore cond_depth to where it was - * when the loop started. + * When breaking out of a .for loop, restore cond_depth to where it was when + * the loop started. */ void -Cond_reset_depth(void) +Cond_ResetDepth(void) { cond_depth = cond_min_depth; } Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.305 src/usr.bin/make/make.h:1.306 --- src/usr.bin/make/make.h:1.305 Fri Sep 23 22:58:15 2022 +++ src/usr.bin/make/make.h Sat Sep 24 10:26:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.305 2022/09/23 22:58:15 sjg Exp $ */ +/* $NetBSD: make.h,v 1.306 2022/09/24 10:26:31 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -799,9 +799,9 @@ void Compat_Make(GNode *, GNode *); /* cond.c */ CondResult Cond_EvalCondition(const char *) MAKE_ATTR_USE; CondResult Cond_EvalLine(const char *) MAKE_ATTR_USE; -void Cond_restore_depth(unsigned int); -void Cond_reset_depth(void); -unsigned int Cond_save_depth(void) MAKE_ATTR_USE; +unsigned int Cond_PushMinDepth(void) MAKE_ATTR_USE; +void Cond_PopMinDepth(unsigned int); +void Cond_ResetDepth(void); /* dir.c; see also dir.h */ Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.684 src/usr.bin/make/parse.c:1.685 --- src/usr.bin/make/parse.c:1.684 Fri Sep 23 22:58:15 2022 +++ src/usr.bin/make/parse.c Sat Sep 24 10:26:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.684 2022/09/23 22:58:15 sjg Exp $ */ +/* $NetBSD: parse.c,v 1.685 2022/09/24 10:26:32 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -105,7 +105,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.684 2022/09/23 22:58:15 sjg Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.685 2022/09/24 10:26:32 rillig Exp $"); /* * A file being read. @@ -119,7 +119,9 @@ typedef struct IncludedFile { unsigned forBodyReadLines; /* the number of physical lines that have * been read from the file above the body of * the .for loop */ - unsigned int cond_depth; /* 'if' nesting when file opened */ + unsigned int including_cond_min_depth; /* depth of nested 'if' + * directives, at the point where the + * including file was opened */ bool depending; /* state of doing_depend on EOF */ Buffer buf; /* the file's content or the body of the .for @@ -2139,7 +2141,7 @@ Parse_PushInput(const char *name, unsign curFile->buf_ptr = curFile->buf.data; curFile->buf_end = curFile->buf.data + curFile->buf.len; - curFile->cond_depth = Cond_save_depth(); + curFile->including_cond_min_depth = Cond_PushMinDepth(); SetParseFile(name); } @@ -2276,7 +2278,7 @@ ParseEOF(void) * Ensure the makefile (or .for loop) didn't have mismatched * conditionals. */ - Cond_restore_depth(curFile->cond_depth); + Cond_PopMinDepth(curFile->including_cond_min_depth); FStr_Done(&curFile->name); Buf_Done(&curFile->buf); @@ -2669,7 +2671,7 @@ HandleBreak(void) if (curFile->forLoop != NULL) { /* pretend we reached EOF */ For_Break(curFile->forLoop); - Cond_reset_depth(); + Cond_ResetDepth(); ParseEOF(); } else Parse_Error(PARSE_FATAL, "break outside of for loop");