summaryrefslogtreecommitdiff
path: root/intrpvar.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2016-04-11 19:11:07 -0600
committerKarl Williamson <khw@cpan.org>2016-05-24 10:26:29 -0600
commitc664130fefeaef47ddc7dcbf7ec1830d04af8ea7 (patch)
tree3f203657dc83b4a2216da92694804e5b020fc2ff /intrpvar.h
parent3c5f993ee8b2fd0912839a82e5d7d8c871a363ea (diff)
downloadperl-c664130fefeaef47ddc7dcbf7ec1830d04af8ea7.tar.gz
locale.c: Change algorithm for strxfrm() trials
It's kind of guess work deciding how big a buffer to give to strxfrm(). If you give it too small a one, it will fail. Prior to this commit, the buffer size was doubled and then strxfrm() was called again, looping until it worked, or we used too much memory. Each time a new locale is made, we try to minimize the necessity of doing this by calculating numbers 'm' and 'b' that can be plugged into the equation mx + b where 'x' is the size of the string passed to strxfrm(). strxfrm() is roughly linear with respect to its input's length, so this generally works without us having to do many loops to get a large enough size. But on many systems, strxfrm(), in failing, returns how much space you should have given it. On such systems, we can just use that number on the 2nd try and not have to keep guessing. This commit changes to do that. But on other systems this doesn't work. So the original method is retained if we determine that there are problems with strxfrm(), either from previous experience, or because using the size returned from the first trial didn't work
Diffstat (limited to 'intrpvar.h')
-rw-r--r--intrpvar.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/intrpvar.h b/intrpvar.h
index 42872e5ba2..f540a9d924 100644
--- a/intrpvar.h
+++ b/intrpvar.h
@@ -565,6 +565,8 @@ PERLVAR(I, collxfrm_base, Size_t) /* Basic overhead in *xfrm() */
PERLVARI(I, collxfrm_mult,Size_t, 2) /* Expansion factor in *xfrm() */
PERLVARI(I, collation_ix, U32, 0) /* Collation generation index */
PERLVARA(I, strxfrm_min_char, 3, char)
+PERLVARI(I, strxfrm_is_behaved, bool, TRUE)
+ /* Assume until proven otherwise that it works */
PERLVARI(I, collation_standard, bool, TRUE)
/* Assume simple collation */
#endif /* USE_LOCALE_COLLATE */