diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/emacs.c b/src/emacs.c index 5a2ac8504c8..7e43d6ad949 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -595,8 +595,14 @@ main (argc, argv, envp) | |||
| 595 | { | 595 | { |
| 596 | long newlim; | 596 | long newlim; |
| 597 | extern int re_max_failures; | 597 | extern int re_max_failures; |
| 598 | /* Approximate the amount regex.c needs, plus some more. */ | 598 | /* Approximate the amount regex.c needs per unit of re_max_failures. */ |
| 599 | newlim = re_max_failures * 2 * 20 * sizeof (char *); | 599 | int ratio = 20 * sizeof (char *); |
| 600 | /* Then add 33% to cover the size of the smaller stacks that regex.c | ||
| 601 | successively allocates and discards, on its way to the maximum. */ | ||
| 602 | ratio += ratio / 3; | ||
| 603 | /* Add in some extra to cover | ||
| 604 | what we're likely to use for other reasons. */ | ||
| 605 | newlim = re_max_failures * ratio + 200000; | ||
| 600 | #ifdef __NetBSD__ | 606 | #ifdef __NetBSD__ |
| 601 | /* NetBSD (at least NetBSD 1.2G and former) has a bug in its | 607 | /* NetBSD (at least NetBSD 1.2G and former) has a bug in its |
| 602 | stack allocation routine for new process that the allocation | 608 | stack allocation routine for new process that the allocation |
| @@ -607,8 +613,8 @@ main (argc, argv, envp) | |||
| 607 | if (newlim > rlim.rlim_max) | 613 | if (newlim > rlim.rlim_max) |
| 608 | { | 614 | { |
| 609 | newlim = rlim.rlim_max; | 615 | newlim = rlim.rlim_max; |
| 610 | /* Don't let regex.c overflow the stack. */ | 616 | /* Don't let regex.c overflow the stack we have. */ |
| 611 | re_max_failures = newlim / (2 * 20 * sizeof (char *)); | 617 | re_max_failures = (newlim - 200000) / ratio; |
| 612 | } | 618 | } |
| 613 | if (rlim.rlim_cur < newlim) | 619 | if (rlim.rlim_cur < newlim) |
| 614 | rlim.rlim_cur = newlim; | 620 | rlim.rlim_cur = newlim; |