Module Name: src
Committed By: rillig
Date: Mon Feb 1 22:36:28 UTC 2021
Modified Files:
src/usr.bin/make: str.c
src/usr.bin/make/unit-tests: varmod-match-escape.mk
Log Message:
make: document necessary tests for Str_Match
To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/make/str.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-match-escape.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.80 src/usr.bin/make/str.c:1.81
--- src/usr.bin/make/str.c:1.80 Mon Feb 1 19:46:58 2021
+++ src/usr.bin/make/str.c Mon Feb 1 22:36:28 2021
@@ -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 @@ Str_Match(const char *str, const char *p
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] == '-') {
Index: src/usr.bin/make/unit-tests/varmod-match-escape.mk
diff -u src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.5 src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.6
--- src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.5 Sun Nov 1 19:49:28 2020
+++ src/usr.bin/make/unit-tests/varmod-match-escape.mk Mon Feb 1 22:36:28 2021
@@ -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 @@ VALUES= : :: :\:
. 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:
@:;