regex: diagnose too-large repeat counts in EREs
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 16 Mar 2012 21:17:55 +0000 (14:17 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 16 Mar 2012 21:18:46 +0000 (14:18 -0700)
commit04ff3c185ce44b905653be2935a1794b3c888ce1
treec238afe48965c0d950f62ed4c5276d91f6226d65
parent47834c92f8122f4ba5e6fca5199a4611425bfe69
regex: diagnose too-large repeat counts in EREs

Previously, the code did not diagnose the too-large repeat count
in EREs like 'b{1000000000}'; instead, it silently treated the ERE
as if it were 'b\{1000000000}', which is unexpected.
* lib/regcomp.c (parse_dup_op): Fail with REG_ESIZE if a repeat count
is too large.  REG_ESIZE is used nowhere else, and the diagnostic
is a reasonable one for this problem.  Another option would be to
create a new REG_OVERFLOW error for repeat counts that are too large.
(fetch_number): Return RE_DUP_MAX + 1, not REG_ERROR, if the repeat
count is too large, so that the caller can distinguish the two cases.
* lib/regex.h (_REG_ESIZE): Document that this is now a generic
"Too large" return code, and that repeat counts are one example of this.
ChangeLog
lib/regcomp.c
lib/regex.h