aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2018-08-02 20:39:01 +0300
committerArnold D. Robbins <arnold@skeeve.com>2018-08-02 20:39:01 +0300
commit48f02e6672003d218d4c0348a6add7931522603b (patch)
tree052246fdd311d0bcd540a5ab3c41187a7065a971 /re.c
parent39a49e9e54b19cc8a51f8f6030bef65d7adf952f (diff)
parent3998ed059bbcfc189cd0d6c5762913fbd4ff4e77 (diff)
downloadegawk-48f02e6672003d218d4c0348a6add7931522603b.tar.gz
egawk-48f02e6672003d218d4c0348a6add7931522603b.tar.bz2
egawk-48f02e6672003d218d4c0348a6add7931522603b.zip
Merge branch 'gawk-4.2-stable'
Diffstat (limited to 're.c')
-rw-r--r--re.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/re.c b/re.c
index eedd05ac..eefdfcd7 100644
--- a/re.c
+++ b/re.c
@@ -100,6 +100,12 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal)
}
}
+ const char *ok_to_escape;
+ if (do_traditional)
+ ok_to_escape = "()|*+?.^$\\[]/-";
+ else
+ ok_to_escape = "<>`'BywWsS{}()|*+?.^$\\[]/-";
+
/* We skip multibyte character, since it must not be a special
character. */
if ((gawk_mb_cur_max == 1 || ! is_multibyte) &&
@@ -141,6 +147,14 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal)
case '9': /* a\9b not valid */
*dest++ = c;
src++;
+ {
+ static bool warned[2];
+
+ if (! warned[c - '8']) {
+ warning(_("regexp escape sequence `\\%c' treated as plain `%c'"), c, c);
+ warned[c - '8'] = true;
+ }
+ }
break;
case 'y': /* normally \b */
/* gnu regex op */
@@ -152,6 +166,14 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal)
}
/* else, fall through */
default:
+ if (strchr(ok_to_escape, c) == NULL) {
+ static bool warned[256];
+
+ if (! warned[c & 0xFF]) {
+ warning(_("regexp escape sequence `\\%c' is not a known regexp operator"), c);
+ warned[c & 0xFF] = true;
+ }
+ }
*dest++ = '\\';
*dest++ = (char) c;
src++;