Fixed wrong step in max_length proof
This commit is contained in:
parent
1dcba90eb3
commit
e8443cd071
1 changed files with 15 additions and 10 deletions
|
@ -218,21 +218,26 @@ static int transform(const char *pattern, char *result, const char **errmsg) {
|
|||
* We must now find the maximal length L such as ∀s, L >= length(T(s))
|
||||
*
|
||||
* It is immediately apparent that the largest string will depend on the number
|
||||
* of occurrences of '!()'. Hence, let s be a string that is a repeating
|
||||
* sequence of '!()',
|
||||
* of occurrences of '!()'. Hence, let u be a string that is a repeating
|
||||
* sequence of '!()' padded by '.' to a multiple of 3,
|
||||
*
|
||||
* let N = floor(length(s) / 3),
|
||||
* let Q = length(s) mod 3,
|
||||
* ∀s, num('!()') = N (1)
|
||||
* let N = floor(length(u) / 3),
|
||||
* let Q = length(u) mod 3,
|
||||
* hence num('!()') = N.
|
||||
*
|
||||
* ∀s, length(T(s)) <= length(s) + 4 * N
|
||||
* <= 3 * N + Q + 4 * N
|
||||
* <= 7 * N + 2
|
||||
* <= 7 * floor(length(s) / 3) + 2
|
||||
* ∀s | lenght(s) = length(u),
|
||||
* length(T(s)) <= length(T(u))
|
||||
* <= length(u) | the original length
|
||||
* + 4 * N | the expansion of all '!()'
|
||||
* + Q * diff('.') | the expansion of Q '.'
|
||||
* <= 3 * N + Q + 4 * N + Q
|
||||
* <= 7 * N + 4
|
||||
* <= 7 * floor(length(u) / 3) + 4
|
||||
* <= 7 * floor(length(s) / 3) + 4
|
||||
*
|
||||
*/
|
||||
static inline size_t max_length(size_t len) {
|
||||
return 7 * len / 3 + 2;
|
||||
return 7 * len / 3 + 4;
|
||||
}
|
||||
|
||||
int extmatch(const char *pattern, const char *string, const char **errmsg) {
|
||||
|
|
Loading…
Add table
Reference in a new issue