diff options
author | Noam Postavsky <npostavs@gmail.com> | 2017-12-11 18:53:34 -0500 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2018-01-26 20:49:44 -0500 |
commit | 559f1606166822394df3988c18c0ad02984ac675 (patch) | |
tree | 68a6e881e690e48bf3d3cd64ef3c5430d511b295 /src/regex.h | |
parent | f5357b1ca4ae90e7ad6d8321884319cfdf828508 (diff) | |
download | emacs-559f1606166822394df3988c18c0ad02984ac675.tar.gz emacs-559f1606166822394df3988c18c0ad02984ac675.tar.bz2 emacs-559f1606166822394df3988c18c0ad02984ac675.zip |
Raise limit of regexp repetition (Bug#24914)
* src/regex.h (RE_DUP_MAX): Raise limit to 2^16-1.
* etc/NEWS: Announce it.
* doc/lispref/searching.texi (Regexp Backslash): Document it.
* test/src/regex-tests.el (regex-repeat-limit): Test it.
* src/regex.h (reg_errcode_t): Add REG_ESIZEBR code.
* src/regex.c (re_error_msgid): Add corresponding entry.
(GET_INTERVAL_COUNT): Return it instead of the more generic REG_EBADBR
when encountering a repetition greater than RE_DUP_MAX.
* lisp/isearch.el (isearch-search): Don't convert errors starting with
"Invalid" into "incomplete". Such errors are not incomplete, in the
sense that they cannot be corrected by appending more characters to
the end of the regexp. The affected error messages are:
- REG_BADPAT "Invalid regular expression"
- \\(?X:\\) where X is not a legal group number
- \\_X where X is not < or >
- REG_ECOLLATE "Invalid collation character"
- There is no code to throw this.
- REG_ECTYPE "Invalid character class name"
- [[:foo:] where foo is not a valid class name
- REG_ESUBREG "Invalid back reference"
- \N where N is referenced before matching group N
- REG_BADBR "Invalid content of \\{\\}"
- \\{N,M\\} where N < 0, M < N, M or N larger than max
- \\{NX where X is not a digit or backslash
- \\{N\\X where X is not a }
- REG_ERANGE "Invalid range end"
- There is no code to throw this.
- REG_BADRPT "Invalid preceding regular expression"
- We never throw this. It would usually indicate a "*" with no
preceding regexp text, but Emacs allows that to match a literal
"*".
Diffstat (limited to 'src/regex.h')
-rw-r--r-- | src/regex.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/regex.h b/src/regex.h index b4aad6daac9..6974951f575 100644 --- a/src/regex.h +++ b/src/regex.h @@ -270,8 +270,10 @@ extern ptrdiff_t emacs_re_safe_alloca; #ifdef RE_DUP_MAX # undef RE_DUP_MAX #endif -/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */ -#define RE_DUP_MAX (0x7fff) +/* Repeat counts are stored in opcodes as 2 byte integers. This was + previously limited to 7fff because the parsing code uses signed + ints. But Emacs only runs on 32 bit platforms anyway. */ +#define RE_DUP_MAX (0xffff) /* POSIX `cflags' bits (i.e., information for `regcomp'). */ @@ -337,7 +339,8 @@ typedef enum REG_EEND, /* Premature end. */ REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ REG_ERPAREN, /* Unmatched ) or \); not returned from regcomp. */ - REG_ERANGEX /* Range striding over charsets. */ + REG_ERANGEX, /* Range striding over charsets. */ + REG_ESIZEBR /* n or m too big in \{n,m\} */ } reg_errcode_t; /* This data structure represents a compiled pattern. Before calling |