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: document necessary tests for Str_Match



details:   https://anonhg.NetBSD.org/src/rev/00acd1f20952
branches:  trunk
changeset: 959147:00acd1f20952
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Feb 01 22:36:28 2021 +0000

description:
make: document necessary tests for Str_Match

diffstat:

 usr.bin/make/str.c                             |  16 +++++++++++-----
 usr.bin/make/unit-tests/varmod-match-escape.mk |  20 +++++++++++++++++++-
 2 files changed, 30 insertions(+), 6 deletions(-)

diffs (70 lines):

diff -r 16e10ace39bd -r 00acd1f20952 usr.bin/make/str.c
--- a/usr.bin/make/str.c        Mon Feb 01 22:21:33 2021 +0000
+++ b/usr.bin/make/str.c        Mon Feb 01 22:36:28 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: str.c,v 1.80 2021/02/01 19:46:58 rillig Exp $  */
+/*     $NetBSD: str.c,v 1.81 2021/02/01 22:36:28 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
 #include "make.h"
 
 /*     "@(#)str.c      5.8 (Berkeley) 6/1/90"  */
-MAKE_RCSID("$NetBSD: str.c,v 1.80 2021/02/01 19:46:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.81 2021/02/01 22:36:28 rillig Exp $");
 
 /* Return the concatenation of s1 and s2, freshly allocated. */
 char *
@@ -324,9 +324,15 @@
                                                break;
                                        return FALSE;
                                }
-                               /* XXX: This naive comparison makes the parser
-                                * for the pattern dependent on the actual of
-                                * the string.  This is unpredictable. */
+                               /*
+                                * XXX: This naive comparison makes the
+                                * control flow of the pattern parser
+                                * dependent on the actual value of the
+                                * string.  This is unpredictable.  It may be
+                                * though that the code only looks wrong but
+                                * actually all code paths result in the same
+                                * behavior.  This needs further tests.
+                                */
                                if (*pat == *str)
                                        break;
                                if (pat[1] == '-') {
diff -r 16e10ace39bd -r 00acd1f20952 usr.bin/make/unit-tests/varmod-match-escape.mk
--- a/usr.bin/make/unit-tests/varmod-match-escape.mk    Mon Feb 01 22:21:33 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-match-escape.mk    Mon Feb 01 22:36:28 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match-escape.mk,v 1.5 2020/11/01 19:49:28 rillig Exp $
+# $NetBSD: varmod-match-escape.mk,v 1.6 2021/02/01 22:36:28 rillig Exp $
 #
 # As of 2020-08-01, the :M and :N modifiers interpret backslashes differently,
 # depending on whether there was a variable expression somewhere before the
@@ -68,5 +68,23 @@
 .  error
 .endif
 
+# The control flow of the pattern parser depends on the actual string that
+# is being matched.  There needs to be either a test that shows a difference
+# in behavior, or a proof that the behavior does not depend on the actual
+# string.
+#
+# TODO: Str_Match("a-z]", "[a-z]")
+# TODO: Str_Match("012", "[0-]]")
+# TODO: Str_Match("0]", "[0-]]")
+# TODO: Str_Match("1]", "[0-]]")
+# TODO: Str_Match("[", "[[]")
+# TODO: Str_Match("]", "[]")
+# TODO: Str_Match("]", "[[-]]")
+
+# In brackets, the backslash is just an ordinary character.
+# Outside brackets, it is an escape character for a few special characters.
+# TODO: Str_Match("\\", "[\\-]]")
+# TODO: Str_Match("-]", "[\\-]]")
+
 all:
        @:;



Home | Main Index | Thread Index | Old Index