summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2018-09-26 16:26:25 +0300
committerArnold D. Robbins <arnold@skeeve.com>2018-09-26 16:26:25 +0300
commitc25c88f583c984112055fa091d357c1b8538d5d8 (patch)
treea971b8150c89a3f00e816c14bfc6cacb2f96c1d4 /re.c
parent26b1a15e75cc1d134e8b52b0df9a5d1365e66d8f (diff)
downloadgawk-c25c88f583c984112055fa091d357c1b8538d5d8.tar.gz
Add more lint warnings.
Diffstat (limited to 're.c')
-rw-r--r--re.c12
1 files changed, 12 insertions, 0 deletions
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 */