Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Do not report unmatched regex subexpressions



details:   https://anonhg.NetBSD.org/src/rev/6ec8e4f6df65
branches:  trunk
changeset: 379826:6ec8e4f6df65
user:      sjg <sjg%NetBSD.org@localhost>
date:      Mon Jun 21 04:24:17 2021 +0000

description:
Do not report unmatched regex subexpressions

It is not always an error for a subexpression to have not matched,
since the regex library can/does not convey how many matches are
expected, only report an error if opts.strict (-dL)

Reviewed by: christos

diffstat:

 usr.bin/make/unit-tests/moderrs.exp |   2 +-
 usr.bin/make/unit-tests/moderrs.mk  |   5 ++++-
 usr.bin/make/var.c                  |  12 +++++++-----
 3 files changed, 12 insertions(+), 7 deletions(-)

diffs (57 lines):

diff -r 3aca937ad044 -r 6ec8e4f6df65 usr.bin/make/unit-tests/moderrs.exp
--- a/usr.bin/make/unit-tests/moderrs.exp       Mon Jun 21 03:14:40 2021 +0000
+++ b/usr.bin/make/unit-tests/moderrs.exp       Mon Jun 21 04:24:17 2021 +0000
@@ -143,4 +143,4 @@ make: Unclosed variable expression, expe
 
 1 1 2 x3 5 8 1x3 21 34
 
-exit status 0
+exit status 2
diff -r 3aca937ad044 -r 6ec8e4f6df65 usr.bin/make/unit-tests/moderrs.mk
--- a/usr.bin/make/unit-tests/moderrs.mk        Mon Jun 21 03:14:40 2021 +0000
+++ b/usr.bin/make/unit-tests/moderrs.mk        Mon Jun 21 04:24:17 2021 +0000
@@ -1,7 +1,10 @@
-# $NetBSD: moderrs.mk,v 1.27 2021/02/23 16:04:16 rillig Exp $
+# $NetBSD: moderrs.mk,v 1.28 2021/06/21 04:24:17 sjg Exp $
 #
 # various modifier error tests
 
+# report unmatched subexpressions
+.MAKEFLAGS: -dL
+
 '=             '\''
 VAR=           TheVariable
 # in case we have to change it ;-)
diff -r 3aca937ad044 -r 6ec8e4f6df65 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Jun 21 03:14:40 2021 +0000
+++ b/usr.bin/make/var.c        Mon Jun 21 04:24:17 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.932 2021/05/30 20:41:34 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.933 2021/06/21 04:24:17 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.932 2021/05/30 20:41:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.933 2021/06/21 04:24:17 sjg Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1651,9 +1651,11 @@ tryagain:
                                        Error("No subexpression \\%u",
                                            (unsigned)n);
                                } else if (m[n].rm_so == -1) {
-                                       Error(
-                                           "No match for subexpression \\%u",
-                                           (unsigned)n);
+                                       if (opts.strict) {
+                                               Error(
+                                                   "No match for subexpression \\%u",
+                                                       (unsigned)n);
+                                       }
                                } else {
                                        SepBuf_AddBytesBetween(buf,
                                            wp + m[n].rm_so, wp + m[n].rm_eo);



Home | Main Index | Thread Index | Old Index