diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2018-08-02 20:43:56 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2018-08-02 20:43:56 +0300 |
commit | b32c67e0f99672ad4104cee4695b5eb040df16f4 (patch) | |
tree | f59c2329e2183fb12e4496306bb7893620bb966c /re.c | |
parent | b98257919b20bdfc14f363761cc6215c1ad8bcee (diff) | |
parent | 3998ed059bbcfc189cd0d6c5762913fbd4ff4e77 (diff) | |
download | egawk-b32c67e0f99672ad4104cee4695b5eb040df16f4.tar.gz egawk-b32c67e0f99672ad4104cee4695b5eb040df16f4.tar.bz2 egawk-b32c67e0f99672ad4104cee4695b5eb040df16f4.zip |
Merge branch 'gawk-4.2-stable' into feature/gnulib-regex
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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++; |