diff options
author | Karl Williamson <public@khwilliamson.com> | 2011-11-10 14:37:40 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2011-11-10 15:20:35 -0700 |
commit | 6cb05c1297bd28c9e4ce45c2a348975ba0ca440a (patch) | |
tree | e3a69dade935f5aa3b6cc483ad03953fef3faeb7 /utf8.c | |
parent | 361ee0fee4b8bd4b4b3691b3b764350ae48d498b (diff) | |
download | perl-6cb05c1297bd28c9e4ce45c2a348975ba0ca440a.tar.gz |
utf8.c: Handle swashes at UV_MAX
The code assumed that there is a code point above the highest value we
are looking at. That is true except when we are looking at the highest
representable code point on the machine. A special case is needed for
that.
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -2651,6 +2651,10 @@ S_swash_get(pTHX_ SV* swash, UV start, UV span) STRLEN offset; if (key >= end) goto go_out_list; + /* XXX If it should ever happen (very unlikely) that we would + * want a non-binary result for the code point at UV_MAX, + * special handling would need to be inserted here, as is done + * below for the binary case */ /* offset must be non-negative (start <= min <= key < end) */ offset = octets * (key - start); if (bits == 8) @@ -2674,6 +2678,15 @@ S_swash_get(pTHX_ SV* swash, UV start, UV span) UV key; if (min < start) min = start; + + /* Special case when the upper-end is the highest possible code + * point representable on the platform. Otherwise, the code below + * exits before setting this bit. Done here to avoid testing for + * this extremely unlikely possibility in the loop */ + if (UNLIKELY(end == UV_MAX && max == UV_MAX)) { + const STRLEN offset = (STRLEN)(max - start); + s[offset >> 3] |= 1 << (offset & 7); + } for (key = min; key <= max; key++) { const STRLEN offset = (STRLEN)(key - start); if (key >= end) |