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): error out if an '.endif' contains extr...



details:   https://anonhg.NetBSD.org/src/rev/1cdfa6796dba
branches:  trunk
changeset: 957906:1cdfa6796dba
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 14 21:56:17 2020 +0000

description:
make(1): error out if an '.endif' contains extraneous text

diffstat:

 usr.bin/make/cond.c                         |   9 ++++++---
 usr.bin/make/unit-tests/directive-endif.exp |   6 +++++-
 usr.bin/make/unit-tests/directive-endif.mk  |  13 ++++++++-----
 3 files changed, 19 insertions(+), 9 deletions(-)

diffs (91 lines):

diff -r 0f5672e8f027 -r 1cdfa6796dba usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Mon Dec 14 21:35:21 2020 +0000
+++ b/usr.bin/make/cond.c       Mon Dec 14 21:56:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.224 2020/12/14 21:35:21 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.225 2020/12/14 21:56:17 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -94,7 +94,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.224 2020/12/14 21:35:21 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.225 2020/12/14 21:56:17 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -1162,7 +1162,10 @@
        cpp_skip_hspace(&p);
 
        if (IsEndif(p)) {       /* It is an '.endif'. */
-               /* TODO: check for extraneous <cond> */
+               if (p[5] != '\0') {
+                       Parse_Error(PARSE_FATAL,
+                           "The .endif directive does not take arguments.");
+               }
 
                if (cond_depth == cond_min_depth) {
                        Parse_Error(PARSE_FATAL, "if-less endif");
diff -r 0f5672e8f027 -r 1cdfa6796dba usr.bin/make/unit-tests/directive-endif.exp
--- a/usr.bin/make/unit-tests/directive-endif.exp       Mon Dec 14 21:35:21 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-endif.exp       Mon Dec 14 21:56:17 2020 +0000
@@ -1,4 +1,8 @@
-make: "directive-endif.mk" line 42: Unknown directive "endifx"
+make: "directive-endif.mk" line 18: The .endif directive does not take arguments.
+make: "directive-endif.mk" line 23: The .endif directive does not take arguments.
+make: "directive-endif.mk" line 33: The .endif directive does not take arguments.
+make: "directive-endif.mk" line 39: The .endif directive does not take arguments.
+make: "directive-endif.mk" line 45: Unknown directive "endifx"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 0f5672e8f027 -r 1cdfa6796dba usr.bin/make/unit-tests/directive-endif.mk
--- a/usr.bin/make/unit-tests/directive-endif.mk        Mon Dec 14 21:35:21 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-endif.mk        Mon Dec 14 21:56:17 2020 +0000
@@ -1,7 +1,10 @@
-# $NetBSD: directive-endif.mk,v 1.4 2020/12/14 20:57:31 rillig Exp $
+# $NetBSD: directive-endif.mk,v 1.5 2020/12/14 21:56:17 rillig Exp $
 #
 # Tests for the .endif directive.
 #
+# Since 2020-12-15, the .endif directive no longer accepts arguments.
+# The manual page had never allowed that, but the code didn't check it.
+#
 # See also:
 #      Cond_EvalLine
 
@@ -10,13 +13,13 @@
 .MAKEFLAGS: -dL
 
 # Error: .endif does not take arguments
-# XXX: Missing error message
 .if 0
+# Since 2020-12-15, complain about the extra text after the 'endif'.
 .endif 0
 
 # Error: .endif does not take arguments
-# XXX: Missing error message
 .if 1
+# Since 2020-12-15, complain about the extra text after the 'endif'.
 .endif 1
 
 # Comments are allowed after an '.endif'.
@@ -25,14 +28,14 @@
 
 # Only whitespace and comments are allowed after an '.endif', but nothing
 # else.
-# XXX: Missing error message
 .if 1
+# Since 2020-12-15, complain about the extra text after the 'endif'.
 .endif0
 
 # Only whitespace and comments are allowed after an '.endif', but nothing
 # else.
-# XXX: Missing error message
 .if 1
+# Since 2020-12-15, complain about the extra text after the 'endif'.
 .endif/
 
 # After an '.endif', no other letter must occur.  This 'endifx' is not



Home | Main Index | Thread Index | Old Index