diff options
| author | sjg <sjg@NetBSD.org> | 2022-09-02 16:24:31 +0000 |
|---|---|---|
| committer | sjg <sjg@NetBSD.org> | 2022-09-02 16:24:31 +0000 |
| commit | b7bcc178e391335d538accb7b91e6e67b58a2dbf (patch) | |
| tree | 3dcf663e05350a0a472e56d3b4b34ed253b7a952 /usr.bin/make/parse.c | |
| parent | 7b79d1b834961e1ac8a6fb5be9b6806d82c3497d (diff) | |
make: add .break to terminate .for loop early
When .break is encountered within a .for loop
it causes immediate termination.
Outside of a .for loop .break causes a parse error.
Reviewed by: christos
Diffstat (limited to 'usr.bin/make/parse.c')
| -rw-r--r-- | usr.bin/make/parse.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 3fa2fa97358..cfbb77af054 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.681 2022/07/24 20:25:23 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.682 2022/09/02 16:24:31 sjg 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.681 2022/07/24 20:25:23 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.682 2022/09/02 16:24:31 sjg Exp $"); /* * A file being read. @@ -2689,7 +2689,17 @@ ParseDirective(char *line) pp_skip_whitespace(&cp); arg = cp; - if (Substring_Equals(dir, "undef")) + if (Substring_Equals(dir, "break")) { + IncludedFile *curFile = CurFile(); + + if (curFile->forLoop != NULL) { + /* pretend we reached EOF */ + For_Break(curFile->forLoop); + Cond_reset_depth(curFile->cond_depth); + ParseEOF(); + } else + Parse_Error(PARSE_FATAL, "break outside of for loop"); + } else if (Substring_Equals(dir, "undef")) Var_Undef(arg); else if (Substring_Equals(dir, "export")) Var_Export(VEM_PLAIN, arg); |
