From c25c88f583c984112055fa091d357c1b8538d5d8 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 26 Sep 2018 16:26:25 +0300 Subject: Add more lint warnings. --- re.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 're.c') diff --git a/re.c b/re.c index a693a9ad..d7724001 100644 --- a/re.c +++ b/re.c @@ -51,6 +51,12 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal) static bool no_dfa = false; int i; static struct dfa* dfaregs[2] = { NULL, NULL }; + static bool nul_warned = false; + + if (do_lint && ! nul_warned && memchr(s, '\0', len) != NULL) { + nul_warned = true; + lintwarn(_("behavior of matching a regexp containing NUL characters is not defined by POSIX")); + } /* * The number of bytes in the current multibyte character. @@ -148,6 +154,12 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal) && strchr("()|*+?.^$\\[]", c2) != NULL) *dest++ = '\\'; *dest++ = (char) c2; + if (do_lint + && ! nul_warned + && c2 == '\0') { + nul_warned = true; + lintwarn(_("behavior of matching a regexp containing NUL characters is not defined by POSIX")); + } break; case '8': case '9': /* a\9b not valid */ -- cgit v1.2.1