make: document necessary tests for Str_Match

This commit is contained in:
rillig 2021-02-01 22:36:28 +00:00
parent af3617fb7b
commit 21f0a9e6c9
2 changed files with 30 additions and 6 deletions

View File

@ -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 * Copyright (c) 1988, 1989, 1990, 1993
@ -71,7 +71,7 @@
#include "make.h" #include "make.h"
/* "@(#)str.c 5.8 (Berkeley) 6/1/90" */ /* "@(#)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. */ /* Return the concatenation of s1 and s2, freshly allocated. */
char * char *
@ -324,9 +324,15 @@ Str_Match(const char *str, const char *pat)
break; break;
return FALSE; return FALSE;
} }
/* XXX: This naive comparison makes the parser /*
* for the pattern dependent on the actual of * XXX: This naive comparison makes the
* the string. This is unpredictable. */ * 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) if (*pat == *str)
break; break;
if (pat[1] == '-') { if (pat[1] == '-') {

View File

@ -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, # As of 2020-08-01, the :M and :N modifiers interpret backslashes differently,
# depending on whether there was a variable expression somewhere before the # depending on whether there was a variable expression somewhere before the
@ -68,5 +68,23 @@ VALUES= : :: :\:
. error . error
.endif .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: all:
@:; @:;