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: error out on a .break directive with argu...



details:   https://anonhg.NetBSD.org/src/rev/f909f50b5877
branches:  trunk
changeset: 376103:f909f50b5877
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jun 01 06:25:34 2023 +0000

description:
make: error out on a .break directive with arguments

diffstat:

 usr.bin/make/parse.c                            |  12 ++++++++----
 usr.bin/make/unit-tests/directive-for-break.exp |   3 ++-
 usr.bin/make/unit-tests/directive-for-break.mk  |  10 +++++++++-
 3 files changed, 19 insertions(+), 6 deletions(-)

diffs (78 lines):

diff -r d10d61ab219a -r f909f50b5877 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Thu Jun 01 04:08:36 2023 +0000
+++ b/usr.bin/make/parse.c      Thu Jun 01 06:25:34 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.698 2023/05/10 16:10:02 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.699 2023/06/01 06:25:34 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.698 2023/05/10 16:10:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.699 2023/06/01 06:25:34 rillig Exp $");
 
 /*
  * A file being read.
@@ -2700,10 +2700,14 @@ ParseLine_ShellCommand(const char *p)
 }
 
 static void
-HandleBreak(void)
+HandleBreak(const char *arg)
 {
        IncludedFile *curFile = CurFile();
 
+       if (arg[0] != '\0')
+               Parse_Error(PARSE_FATAL,
+                   "The .break directive does not take arguments");
+
        if (curFile->forLoop != NULL) {
                /* pretend we reached EOF */
                For_Break(curFile->forLoop);
@@ -2742,7 +2746,7 @@ ParseDirective(char *line)
        arg = cp;
 
        if (Substring_Equals(dir, "break"))
-               HandleBreak();
+               HandleBreak(arg);
        else if (Substring_Equals(dir, "undef"))
                Var_Undef(arg);
        else if (Substring_Equals(dir, "export"))
diff -r d10d61ab219a -r f909f50b5877 usr.bin/make/unit-tests/directive-for-break.exp
--- a/usr.bin/make/unit-tests/directive-for-break.exp   Thu Jun 01 04:08:36 2023 +0000
+++ b/usr.bin/make/unit-tests/directive-for-break.exp   Thu Jun 01 06:25:34 2023 +0000
@@ -1,4 +1,5 @@
-make: "directive-for-break.mk" line 45: break outside of for loop
+make: "directive-for-break.mk" line 47: break outside of for loop
+make: "directive-for-break.mk" line 67: The .break directive does not take arguments
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r d10d61ab219a -r f909f50b5877 usr.bin/make/unit-tests/directive-for-break.mk
--- a/usr.bin/make/unit-tests/directive-for-break.mk    Thu Jun 01 04:08:36 2023 +0000
+++ b/usr.bin/make/unit-tests/directive-for-break.mk    Thu Jun 01 06:25:34 2023 +0000
@@ -1,8 +1,10 @@
-# $NetBSD: directive-for-break.mk,v 1.3 2022/09/24 10:52:05 rillig Exp $
+# $NetBSD: directive-for-break.mk,v 1.4 2023/06/01 06:25:34 rillig Exp $
 #
 # Tests for .break in .for loops, which immediately terminates processing of
 # the surrounding .for loop.
 
+# expect-all
+
 
 # .break terminates the loop early.
 # This is usually done within a conditional.
@@ -58,3 +60,9 @@ COMBINED+=    ${outer}-${inner}
 .    endfor
 .  endif
 .endif
+
+
+.for i in 1
+# expect+1: The .break directive does not take arguments
+.  break 1
+.endfor



Home | Main Index | Thread Index | Old Index